nodejs web3 bsc bep20 token transfer gas price need BNB or EHT

212 views Asked by At

I have a question and would like to ask it.
I am currently using nodejs based on web3 and my wallet also goes to Ethereum based on web3.
The token currently used is BEP20.

let contract= new web3.eth.Contract(TOKEN_ABI, TOKEN_ADDRESS)
await contract.methods.transfer(toAddress, transFerValue).send({from: defaultAddress})

If I send some of BEP20 to someone, Which coin for gas price do I use ETH or BNB?
I mean that Do I need BNB or ETH to pay for gas?

var rawTransaction = {
    "from": senderWalletAddress,
    "nonce": "0x" + count.toString(16),
    "gasPrice": web3.utils.toHex(gasPriceGwei * 1e9),
    "gasLimit": web3.utils.toHex(gasLimit),
    "to": contractAddress,
    "value": "0x0",
    "chainId": 56,
    "data": contract.methods.transfer(receiverWalletAddress, transferAmount).encodeABI(),
};

const chain = Common.default.forCustomChain(
    'mainnet', {
        name: 'bnb',
        networkId: 56,
        chainId: 56
    },
    'petersburg'
)

/* generate transaction including my block chain */
var tx = new Tx(rawTransaction, {common: chain});
1

There are 1 answers

0
vidhyesh On BEST ANSWER

You need ETH, because you are transferring BNB token in Ethereum network so you should pay gas fee to mine that transaction more gas you pay, your transaction will be mined quickly

Better you could try those things in testnet so that you know basic things, deploy your own ERC20 contract and try to transfer it

For more info about gas fee ref: investopedia.com/terms/g/gas-ethereum.asp