简体   繁体   中英

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?

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

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.

A user has even mentioned a full working example at 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.

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. OpenGSN ( https://opengsn.org/ ) provides an implementation. To quickly grasp the idea, read (now depricated) https://docs.openzeppelin.com/learn/sending-gasless-transactions

Let me just quote the relevant part from OZ docs:

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. 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. 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.

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.

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