[英]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.我可以通过使用上述代码从一个地址到另一个地址轻松发送 bep20 令牌,并且它工作正常,但在这种情况下,我需要从 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?
使用 web3 转账 bep20 代币时,有什么方法可以从其他账户支付 gas 费吗? 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.我假设您的目标是不向代币所有者支付任何费用,因此
approve()
function 也是不可能的。 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.如果不是这种情况,代币所有者可以调用
approve()
function(为此支付gas费用;允许指定的花费者花费他们的代币),然后花费者可以调用transferFrom()
指定从哪个地址(所有者谁批准他们使用代币)他们想要转移代币。
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.有一些代币合约允许通过接受代币所有者签署的消息到由交易发送者调用的自定义 function 进行元转移 - 有效地从所有者那里转移代币以及由 tx 发送者支付的所有费用。 But that requires a custom implementation that the BUSD contract (as well as most token contracts) doesn't implement.
但这需要 BUSD 合约(以及大多数代币合约)没有实现的自定义实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.