简体   繁体   English

使用 web3 转账 bep20 代币时,如何从另一个账户支付 gas 费用?

[英]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.

相关问题 在我的 BEP20 Token 代码中使用 import 语句会影响我的未来吗? - Will using import statement in my BEP20 Token code affect me in the future? Web3:从地址中检索 ERC20 代币的余额 - Web3: retrieving the balance of an ERC20 token from an address 如何在 SOLANA 上使用 web3 js 从令牌地址获取元数据 - How to get Metadata from a Token adress using web3 js on SOLANA 如何在 solana Web3 中获取令牌计数 - How to grab the Token count in solana Web3 使用web3 Ropsten Infura TestNet传输ERC20令牌 - Transferring ERC20 Tokens using web3 Ropsten Infura TestNet 如何使用 web3 js 在 pancakeswap 上交换令牌 - how to swap tokens on pancakeswap using web3 js 如何集成erc20令牌功能以制作转移令牌并检查余额? - How to integrate a erc20 token function, to make transfer token and check balance? 如何将 jwt 令牌从 web 浏览器上的本地存储传输到服务器后端? - How do I transfer a jwt token from local storage on the web browser to the server backend? 如何在从javascript传递到web api 2时隐藏或保护令牌 - how to hide or secure the token when passing from javascript to web api 2 如何使用外部登录从Web API 2获取令牌 - How to get token from Web API 2 using external login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM