简体   繁体   English

不使用 ETH 转移 ERC20 代币

[英]Transfer ERC20 token without ETH

I would like to transfer ERC20 tokens from a wallet who don't own ETH to another wallet who own ETH and who can pay gas fee.我想将 ERC20 代币从一个不拥有 ETH 的钱包转移到另一个拥有 ETH 并且可以支付 gas 费的钱包。 Do you know if it is possible to made a transfer of ERC20 tokens and to let the receiver wallet pay fees?你知道是否可以转移 ERC20 代币并让接收方钱包支付费用吗?

TLDR: Not possible, unless the token contract explicitly allows it. TLDR:不可能,除非代币合约明确允许。 Or unless the token holder is also the block producer.或者除非代币持有者也是区块生产者。

Transaction fees are paid in ETH (or generally, native currency of the network - for example BNB on Binance Smart Chain, MATIC on Polygon, ...).交易费用以 ETH 支付(或者通常是网络的本地货币 - 例如 Binance Smart Chain 上的 BNB,Polygon 上的 MATIC,......)。 So in most cases, you need to pay ETH to execute either the transfer() function if you want to send the tokens from your address, or the approve() function if you want someone else to transfer tokens from your address.所以在大多数情况下,如果你想从你的地址发送代币,你需要支付 ETH 来执行transfer() approve() ,或者如果你想让其他人从你的地址转移代币,则需要支付 ETH 来执行 transfer() function。

Very few token contracts implement delegated transfer mechanism on top of the ERC20 standard.很少有代币合约在 ERC20 标准之上实现委托转账机制。 There's currently no standardized way to perform a delegated transfer, so each contract might have a different implementation.目前没有标准化的方式来执行委托转账,因此每个合约可能有不同的实现。 The token holder uses their private key to sign a predetermined message saying how many tokens they want to transfer to which address.代币持有者使用他们的私钥签署预先确定的消息,说明他们想要将多少代币转移到哪个地址。 The message also usually contains a nonce or a timestamp to prevent signature replay attack.该消息通常还包含一个随机数或时间戳,以防止签名重放攻击。 Token holder passes the message offchain to the transaction sender, and then the transaction sender executes a function of the token contract built specifically for delegated transfers (note that the transaction sender pays the fee to execute this function).代币持有者将消息链下传递给交易发送者,然后交易发送者执行专门为委托转账构建的代币合约的 function(注意交易发送者支付执行该功能的费用)。 The contract validates the signature, and performs the transfer.合约验证签名并执行传输。 Again, most token contracts do not implement this mechanism.同样,大多数代币合约都没有实现这种机制。

One more exception from the rule is a block producer.该规则的另一个例外是区块生产者。 When you create a new block, you can fill it with transactions not only from the mempool but also with your own transactions.当您创建一个新块时,您不仅可以使用来自内存池的交易填充它,还可以使用您自己的交易填充它。 You can build a transaction with 0 gas price, and then include it in the block that you're producing.你可以建立一个 0 gas 价格的交易,然后将它包含在你正在生产的区块中。 This way you're also able to send tokens for free.通过这种方式,您还可以免费发送代币。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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