I want to send transaction in Binance Smart Chain and I got an error: new Error("Chain with name " + chain + " not supported");
const Tx = require('ethereumjs-tx').Transaction;
const Web3 = require('web3');
const web3 = new Web3("https://mainnet.infura.io/v3/xxx");
const privKey =
Buffer.from('xxx', 'hex');
const addressFrom = '0xXXX';
const addressTo = '0xXXX';
web3.eth.getTransactionCount(addressFrom, (err, txCount) => {
const txObject = {
nonce: web3.utils.toHex(txCount),
to: addressTo,
value: web3.utils.toHex(web3.utils.toWei('0.01', 'ether')),
gasLimit: web3.utils.toHex(100000),
gasPrice: web3.utils.toHex(web3.utils.toWei('100', 'gwei'))
};
const tx = new Tx(txObject, {'chain':'smart chain'});
//const tx = new Tx(txObject, {'chain':'56'});
//const tx = new Tx(txObject, {'chain':'binance'});
tx.sign(privKey);
const serializedTrans = tx.serialize();
const raw = '0x' + serializedTrans.toString('hex');
web3.eth.sendSignedTransaction(raw, (err, txHash) => {
console.log('txHash:', txHash)
});
}
);
And if using these libraries it is impossible to send a transaction, what is better for me to use to send a transaction in Smart Chain? I found a couple of sites https://docs.binance.org/smart-chain/wallet/wallet_api.html and https://github.com/drunken005/binance-utils but it seems to me they are for a regular Binance network (as I see wallets in examples start with bnb...) or am I wrong?