jeudi 26 août 2021

Own testcoins / tokens

I created my own coin/token on remix.ethereum

Now I wanted to make a website where you can connect with your Metamask wallet and then get these worthless coins / tokens for free

I have experience with HTML, CSS

and a bit of JS because I coded with discord.js for 7 months

But I have no idea how I do it and whether it is even possible

Do I have to do my own test network and how?

I tested it like this but it doesn't work and I don't understand would be really nice if someone could help me (yes I know messy)

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
  </script>
</head>

<body>
  <div>
    <button class="pay-button">Pay</button>
    <div id="status"></div>
  </div>
  <script type="text/javascript">
    window.addEventListener('load', async() => {
      if (window.ethereum) {
        window.web3 = new Web3(ethereum);
        try {
          await ethereum.enable();
          initPayButton()
        } catch (err) {
          $('#status').html('User denied account access', err)
        }
      } else if (window.web3) {
        window.web3 = new Web3(web3.currentProvider)
        initPayButton()
      } else {
        $('#status').html('No Metamask (or other Web3 Provider) installed')
      }
    })
    const initPayButton = () => {
      $('.pay-button').click(() => {
        // paymentAddress
        const paymentAddress = '0x01910833896EEdf036A99b2CC34df6Da01BB15E3'
        const amountEth = 1
        web3.eth.sendTransaction({
          to: paymentAddress,
          value: web3.toWei(amountEth, 'ether')
        }, (err, transactionId) => {
          if (err) {
            console.log('Payment failed', err)
            $('#status').html('Payment failed')
          } else {
            console.log('Payment successful', transactionId)
            $('#status').html('Payment successful')
          }
        })
      })
    }
  </script>```

if you need the coin contract adress:
0x7ec4baaa874e77437d45c4f43f6c20ed6d3822a3

created with ropsten testnetwork



Aucun commentaire:

Enregistrer un commentaire