faucet.html 4.68 KB
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="og:locale" content="en_US">
    <meta property="og:type" content="website">
    <meta property="og:title" content="Offshift">
    <meta property="og:description" content="Anonymous alternative to
    centralized, fiat-backed stablecoins">
    <meta property="og:url" content="https://offshift.io/">
    <meta property="og:site_name" content="Offshift">
    <meta property="article:modified_time" content="2020-08-11T09:10:25+00:00">
    <meta property="og:image" content="https://offshift.io/wp-content/uploads/2020/07/Thumb.jpg">
    <meta property="og:image:width" content="1200">
    <meta property="og:image:height" content="630">
    <title>Faucet</title>
    <link href="./mini.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
</head>
<body>
  <div id="main" class="">
    <div class="dark:bg-gradient-to-r dark:from-gray-800 dark:to-gray-900 min-h-screen bg-gradient-to-r from-purple-400 via-pink-500 to-red-500 py-6 flex flex-col justify-center sm:py-12 text-white">
      <div class="dark:bg-gray-800 dark:text-white w-full mx-auto rounded-3xl shadow-lg bg-white px-10 pt-16 pb-10 text-gray-600" style="max-width: 400px" x-data="app()">
        <div class="overflow-hidden relative mb-10">
          <div class="font-semibold text-center text-2xl mb-4 text-gray-900 dark:text-white">TESTNET FAUCET</div>
          <div class="container w-full pt-8">
            <button onclick="faucet();" class="dark:bg-gradient-to-r dark:from-purple-800 ml-12 px-7 py-3 shadow-md no-underline rounded-full bg-gradient-to-r from-green-400 to-blue-500 hover:from-pink-500 hover:to-yellow-500 text-white font-sans font-semibold text-xl border-blue btn-primary hover:text-white hover:bg-blue-light focus:outline-none active:shadow-none mr-2">xftT(testnet) faucet</button>
          </div>
        </div>
      </div>
      <div class="absolute bottom-4 right-3">
        <button id="mode" onclick="changeMode();" class="mb-auto px-3 py-2 shadow-md no-underline rounded-full bg-gradient-to-r from-green-400 to-blue-500 hover:from-pink-500 hover:to-yellow-500 text-white font-sans font-semibold text-xs border-blue btn-primary hover:text-white hover:bg-blue-light focus:outline-none active:shadow-none mr-2 dark:bg-gradient-to-r dark:from-purple-800">dark mode</button>
      </div>
    </div>
  </div>  
</body>
<script>
    ethereum.request({ method: 'eth_requestAccounts' });
    web3 = new Web3(window.ethereum);
    web3.eth.getAccounts(async function(error, accounts) {
      web3.eth.accounts = accounts;
      web3.eth.defaultAccount = accounts[0];
    });
  
    web3.eth.getAccounts(function(error, accounts) {
      web3.eth.defaultAccount = accounts[0];
    })
  
    shift = new web3.eth.Contract([
      {
          "inputs": [
              {
                  "internalType": "address",
                  "name": "_tokenA",
                  "type": "address"
              },
              {
                  "internalType": "address",
                  "name": "_tokenB",
                  "type": "address"
              }
          ],
          "stateMutability": "nonpayable",
          "type": "constructor"
      },
      {
          "anonymous": false,
          "inputs": [
              {
                  "indexed": false,
                  "internalType": "uint256",
                  "name": "value",
                  "type": "uint256"
              }
          ],
          "name": "Shifted",
          "type": "event"
      },
      {
          "inputs": [],
          "name": "faucet",
          "outputs": [],
          "stateMutability": "payable",
          "type": "function"
      },
      {
          "inputs": [
              {
                  "internalType": "uint256",
                  "name": "amount",
                  "type": "uint256"
              }
          ],
          "name": "shift",
          "outputs": [],
          "stateMutability": "nonpayable",
          "type": "function"
      }
  ], "0x6bE4C94052BF34e09d67C255D9Fe564c5abd4f95");
  function faucet() {
      shift.methods.faucet().send({from: ethereum.selectedAddress}).then();
  }


  function changeMode() {
      if (localStorage.theme != 'dark'){
        localStorage.theme = 'dark'; 
        document.getElementById("main").classList.add("dark");
        document.getElementById("mode").textContent = "Dark mode";
      }else {
        localStorage.theme = 'light';
        document.getElementById("main").classList.remove("dark");
        document.getElementById("mode").textContent = "Light mode";
      }
    }
    changeMode();
  </script>
</html>