This article is co-authored by Ivo Georgiev
Preface: Meta Transactions
Meta Transactions are extremely cool. If you do not know about them — you should. You will find useful links below this article.
Changing the Meta Proxy to support batches
The idea behind the Meta Proxy contract(sometimes called Identity Proxy or Identity Contract) is for it to be a representer of the user and obeying to messages only signed by its master. For you to use MetaTx, you (or someone else) must deploy your own MetaProxy that is going to execute your signed messages.
While the community has been focusing on making a better relayer network or standardizing the Meta Proxy, we had the idea to try and batch multiple transactions together. This new-found atomicity of multiple transactions together seems to come quite handy in multiple scenarios. Some of them are:
- ERC-20 approve+transferFrom based interactions
- Decentralized exchanges
The batched transactions are achieved through simply changing the
signature params to arrays. Now, all we do, is loop through them, validating and executing them. If a single transaction fails — the whole batch is going to be reverted. Look for the code below.
Use case: Solving ERC-20 non-atomicity through batched meta transactions
In order to showcase the batched MetaTx, we are going to fight the non-atomicity of the approve-transferFrom mechanism of ERC-20. I’ve gone ahead and created a code example that illustrates that.
The main idea is that we build the two transactions with their signatures and send them to the MetaTx proxy. The two transactions have different a
to, but will be performed in batch.