我想在BSC测试网络上使用web3.js从我的元任务钱包发送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')
}
});
您需要在事务对象中指定chainId: '56'
(BSC-源的ID(。