Meta-Transactions: General Overview

Is it possible to deduct the txn fee from the sent amount when using ERC20?

I recently received such a question in my chat room and immediately wondered… After all, it is possible!


I — Meta-Transactions: General

In the Ethereum world things happen thanks to transactions. These transactions, just like everything in life, don’t come for free. In order to create and execute a transaction you need to pay a fee in the form of “Gas” which costs ETH.

But what if you want to create a transaction and you have no money to pay for gas… this is where Meta-Transactions come to the rescue!

Meta Transactions are transactions who’s data is created and signed off-chain by one person and executed by another person who pays the gas fees.

Since meta transactions are not native to the system, you would need to either use a 3rd party setup (e.g. GSN), or create your own!

The signed transaction parameters are passed onto a secondary network, which acts as a relayer. While there are different schemes for this, relayers would generally choose which transactions are worth submitting by validating the transaction (e.g., being relevant to the dApp).

Upon validation, the relayer will wrap the request (the signed message) into an actual transaction (which means paying the gas fee) and broadcast it to the network, where the contract unwraps the transaction by validating the original signature and executes it on behalf of the user.

The words meta and batch may be analogous to some!

To clarify: a meta transaction is different from a batch transaction, where a batch transaction is a transaction that can send multiple transactions at once and are then executed from a single sender (single nonce specified) in sequence.

In summary, meta transactions are a design pattern where:

  • A user (sender) signs a request with their private key and sends it to a relayer;

  • The relayer wraps the request into a tx and sends it to a contract;

  • The contract unwraps the tx and executes it.

Native transactions imply that the “sender” is also the “payer”. When taking the “payer” away from the “sender”, the “sender” becomes more like an “intender” — the sender shows the intent of the transaction they would like executed on the blockchain by signing a message containing specific parameters related to their message, and not an entirely constructed transaction.

Resources:

Also check out:


II — Sponsored Transactions

Let’s turn to flashbots — this is an organization that is engaged in researching and creating an ecosystem for MEV, with the help of which it is possible to extract additional profit in a block by manipulating the order of transactions!

How it works:

  1. There are miners (pools) that keep a MEV-geth node instead of a standard geth. In the network, about 70% of the hash rate is on MEV-geth, because with it miners get on average 0.3 ETH more per block.

  2. There are researchers — people who find profitable bundles of transactions, and send them to miners via flashbots-relay. The researcher shares the reward with the miners, resulting in their partnership and synergy. See more information on flashbots and scenarios of their use here!

With Sponsored TX you can rescue assets from a compromised wallet!

On compromised wallets hackers usually place a sweeper malware, which instantly steals all of victim’s ether, while often leaving the rest of assets untouched so that the victim feeds the bad guy more ether in an attempt to save the rest.

The only way out of this situation is to send a bundle consisting of several transactions:

Tx1 = Sponsor sends ether to the hacked wallet

Tx2 = Hacked wallet withdraws tokens/ftft to the main wallet

Tx3 = Hacked wallet returns ether to Sponsor

In this case, the sweeper will not be able to steal ether because:

  1. Transactions don’t go to the public mempool, but are sent to the private relay.

  2. In case of a fiasco during simulation of one of the transactions — the whole bundle will be cancelled.

Practice on this private key:

  • 37fb7f5923cda40128a56db4c36c0f060e7e8722b79416e7f4a4130a4452de97

Just don’t take away all the tokens, leave some for others so they can try as well ❗️

Resources:


III - Support

Support is very important to me, with it I can spend less time at work and do what I love — educating!

If you want to support my work, please, send me a donation to the address:

Thank you!

Subscribe to Officer's Blog
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.