Reputation: 1
I want to send BNB from my metamask wallet using web3.js on BSC Test Network. I don't know how I can do it. This code sends ETH in my wallet, but I can't send BNB. I would be glad if you help..
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')
}
});
Upvotes: 0
Views: 5435
Reputation: 43591
You need to specify chainId: '56'
(which is the ID of BSC - source) in the transaction object.
Upvotes: 1