【问题标题】:Own testcoins / tokens自己的测试币/代币
【发布时间】:2021-08-26 07:00:53
【问题描述】:

我在 remix.ethereum 上创建了自己的硬币/代币

现在我想创建一个网站,您可以在其中连接您的 Metamask 钱包,然后免费获得这些毫无价值的硬币/代币

我有 HTML、CSS 方面的经验

还有一点 JS,因为我用 discord.js 编码了 7 个月

但我不知道我是怎么做的,也不知道这是否可能

我必须自己做测试网络吗?如何做?

我是这样测试的 但它不起作用,我不明白 如果有人可以帮助我,那就太好了 (是的,我知道很乱)

  <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

【问题讨论】:

    标签: javascript html web ethereum remix


    【解决方案1】:

    您可以通过infura 访问以太坊主网络和测试网络。您可以获得足够的带宽来测试您的应用程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-12
      • 2020-04-26
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      相关资源
      最近更新 更多