简体   繁体   English

是否可以从以太坊的另一个账户支付交易费用?

[英]Is it possible to pay transaction fee from another account in ethereum?

i want to do a transaction in ethereum from account A but the transaction fee should be paid from account B. is it possible in ethereum?我想从账户 A 进行以太坊交易,但交易费用应该从账户 B 支付。以太坊可以吗?

不,汽油总是由发送交易的帐户支付。

There is no native support for that in the Ethereum network. 以太坊网络没有对此的原生支持。
However THIS particular issue has been actively discussed for a while now. 但是, 这个特定问题已经被讨论了一段时间。
Though the issue above discusses mainly about account B doing token transfer for the account A and earning some tokens for account B as a fee. 尽管以上问题主要讨论的是account Baccount A进行令牌转移并为account B赚取一些令牌作为费用。

A user has even mentioned a full working example at http://lavawallet.io 用户甚至在http://lavawallet.io上提到了完整的工作示例

Currently, there isn't any in-built provision to allow other users to pay the gas fees for a particular transaction. 当前,没有任何内置条款允许其他用户支付特定交易的汽油费。 However, the concept of a contract paying the gas fees by refunding the user exists and can be implemented. 但是,存在并可以实现通过向用户退款来支付汽油费的合同的概念。 This, of course, opens the possibility of attacks on this function to deplete the funds. 当然,这打开了对该功能进行攻击以耗尽资金的可能性。

There is an ongoing discussion here for a future release (Serenity) that can work around the concept of only the account sending the transaction paying the fees. 对于将来的发行版(Serenity), 这里正在进行讨论,可以解决仅发送交易的帐户支付费用的概念。

There is no built-in support in ethereum for that functionality.以太坊中没有对该功能的内置支持。 But there is a popular approach for that problem called Gas Station Network aka GSN.但是有一种流行的方法可以解决这个问题,称为 Gas Station Network aka GSN。 OpenGSN ( https://opengsn.org/ ) provides an implementation. OpenGSN ( https://opengsn.org/ ) 提供了一个实现。 To quickly grasp the idea, read (now depricated) https://docs.openzeppelin.com/learn/sending-gasless-transactions要快速掌握这个想法,请阅读(现已弃用) https://docs.openzeppelin.com/learn/sending-gasless-transactions

Let me just quote the relevant part from OZ docs:让我引用 OZ 文档的相关部分:

This is a fancy name for a simple idea: a third-party (called a relayer) can send another user's transactions and pay themselves for the gas cost.这是一个简单想法的花哨名称:第三方(称为中继器)可以发送另一个用户的交易并为自己支付 gas 费用。 In this scheme, users sign messages (not transactions) containing information about a transaction they would like to execute.在这个方案中,用户签署包含他们想要执行的交易信息的消息(不是交易)。 Relayers are then responsible for signing valid Ethereum transactions with this information and sending them to the network, paying for the gas cost.然后,中继者负责使用此信息签署有效的以太坊交易并将其发送到网络,并支付 gas 费用。 A base contract preserves the identity of the user that originally requested the transaction.基础合约保留了最初请求交易的用户的身份。 In this way, users can interact directly with smart contracts without needing to have a wallet or own Ether.通过这种方式,用户可以直接与智能合约进行交互,而无需拥有钱包或拥有 Ether。

This means that, in order to support meta transactions in your application, you need to keep a relayer process running - or leverage a decentralized relayer network.这意味着,为了在您的应用程序中支持元事务,您需要保持中继进程运行 - 或利用去中心化中继网络。

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

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