简体   繁体   中英

How to paid gas charges from another account when transfer bep20 token using web3?

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

I can send easily bep20 token by using above code from one address to another and its work fine, but in this case I need to pay the gas fee from defaultAddress. But I want to pay the gas fee from another account. Is there any way to pay the gas fee from another account when transfer the bep20 token using web3? I searched a lot but not found any proper answer. If anyone know the answer please response with proper guideline.

Simple answer: No.

I'm assuming your goal is to not pay any fees by the token owner, so the approve() function is out of question as well. If that's not the case, the token owner can invoke the approve() function (paying gas fees for it; allowing a specified spender to spend their tokens), and then the spender can invoke the transferFrom() specifying from which address (the owner who approved them to spend the tokens) they want to transfer the tokens.

There are some token contracts that allow metatransfers by accepting a message signed by the token owner to a custom function that is invoked by the transaction sender - effectively transferring tokens from the owner and all fees paid by the tx sender. But that requires a custom implementation that the BUSD contract (as well as most token contracts) doesn't implement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM