【问题标题】:How can I send BNB with metamask using web3.js (BSC Test Network)如何使用 web3.js(BSC 测试网络)发送带有元掩码的 BNB
【发布时间】:2021-08-04 17:31:23
【问题描述】:

我想在 BSC 测试网络上使用 web3.js 从我的 metamask 钱包发送 BNB。我不知道我该怎么做。此代码在我的钱包中发送 ETH,但我无法发送 BNB。如果你能帮忙我会很高兴..

      const holder = ethereum.selectedAddress;
    // paymentAddress is where funds will be send to
    const paymentAddress = '0xEdccc7De37305372c3a274aF32Bc0eed26D1891C'
    const amount = web3.utils.toWei("0.000011","ether")


    web3.eth.sendTransaction({
        from: holder,
        to: '0x0B75fbeB0BC7CC0e9F9880f78a245046eCBDBB0D',
        value: '1000000000000000000',
    }, function(err, transactionHash) {
      if (err) {
            console.log('Payment failed', err)
            $('#status').html('Payment failed')
        } else {
        console.log(transactionHash);
        $('#status').html('Payment successful')
       }
    });

【问题讨论】:

  • 嗨,你有想过这个吗?

标签: web3js cryptocurrency metamask binance-smart-chain


【解决方案1】:

您需要在交易对象中指定chainId: '56'(即BSC的ID-source)。

【讨论】:

  • 我做到了,但它仍然尝试发送 ETH 而不是 BNB。
猜你喜欢
  • 2023-02-12
  • 2021-03-10
  • 1970-01-01
  • 2021-12-28
  • 1970-01-01
  • 2019-03-08
  • 1970-01-01
  • 2019-02-13
  • 2018-12-05
相关资源
最近更新 更多