0.0.20 • Published 4 years ago

@anydotcrypto/metatransactions v0.0.20

Weekly downloads
347
License
-
Repository
-
Last release
4 years ago

A Minimal Meta-Transaction Library

Ethereum transaction's intertwine the identity of who paid for the transaction (gas.payer) and who wants to execute a command (msg.sender). As a result, it is not straight forward for Alice to pay the gas fee on behalf of Bob who wants to execute a command in a smart contract. Until it is fixed at the platform level, then Alice and Bob must adopt a meta-transaction standard to support this functionality (e.g. transaction infrastructure as a service in a non-custodial manner).

There are two approaches:

  • Proxy contract: Every user has a proxy contract and all transactions are sent via the proxy contract. It is compatible with all existing smart contracts.
  • _msgSender(): All transactions are sent via a single UniversalForwarder contract and the target contract must support the _msgSender() standard. It preserves the user's signing key address as their identity.

Our meta-transaction library focuses on both approaches and we hope it benefits the community in the following way:

  • A Universal Forwarder: Our RelayHub.sol can be used for the _msgSender() standard.
  • Minimal wallet contract: Our proxy contract only requires 67k gas to deploy & 26k gas per transaction. It is minimal code and supports batching transactions. As well, its replay protection supports out of order-transactions (bitflip) and concurrent transactions (multinonce).
  • GnosisSafe: We have incorporated GnosisSafe and our library tracks the replay protection nonce such that it is meta-transaction friendly. It is an audited wallet contract that is increasingly widely used.

Our repository is a protocol and relay-independent approach that any project can adopt. We hope it will make it easier for projects to tap into third party relayer APIs and to avoid re-implementing the wheel for reliable transaction infrastructure.

Getting started

We have put together a guide for the universal forwarder, proxy account and gnosis safe:

  • Universal Forwarder: Tutorial to be completed soon.
  • GnosisSafe Forwarder: An audited wallet contract implementation by Gnosis and we follow the nonce signature path. Thus it is meta-transaction safe.
  • ProxyAccount Forwarder: Our own wallet contract implementation (not audited) with flexible replay protection and minimal overhead.

Our unit tests evaluate the gas costs for the wallet contracts:

NameDeploy Wallet1st Transaction2nd Transaction10 Transactions (AVG)100 Transactions (AVG)Meta-deployment Echo Contract
Gnosis Safe223,24039,01424,01424,00924,01124,9179
Proxy (Bitflip)67,30339,71824,69824,70124,70425,9423
Proxy (Multinonce)67,30339,49039,50239,52127,22825,9239

Deploy wallet. Both proxy contracts are deployed using EIP-1167 which is the minimal clone factory technique. Whereas Gnosis Safe deploys a proxy contract using CREATE2 and then has ~5 storage operations during setup.

1st Transaction. All wallet contracts must initially set the nonce field which results in a higher gas cost.

2nd Transaction. Both Gnosis Safe and Proxy-bitflip are comparable as the nonce field is reused. Multinonce is higher as it supports multiple nonce queues. By default it maintains 10 queues and the implementation cycles through each nonce queue in turn.

10 Transactions.Both Gnosis Safe and Proxy-bitflip are comparable. Multinonce is higher as it supports multiple nonce queues. By default it maintains 10 queues an

100 Transactions. All wallet contracts have comparable gas costs. The nonce field is re-used for every new transaction. The gas cost for bitslip should be around 24k gas for 255 transactions, and then it needs to set a new nonce field which is 39k gas, then it will again be 24k gas for 255 transactions

Meta-deployment Echo Contract. All wallet contracts have comparable gas costs for deploying an echo contract. Each wallet contract delegate calls into a global deployer and the echo contract is deployed using CREATE2. We recommend deploying the contract and then calling an init() method (to avoid any msg.sender issues during deployment).

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.15-6

4 years ago

0.0.15-5

4 years ago

0.0.15-4

4 years ago

0.0.15-3

4 years ago

0.0.15-2

4 years ago

0.0.15-1

4 years ago

0.0.15-0

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.13-15

4 years ago

0.0.13-14

4 years ago

0.0.13-13

4 years ago

0.0.13-12

4 years ago

0.0.13-11

4 years ago

0.0.13-10

4 years ago

0.0.13-9

4 years ago

0.0.13-8

4 years ago

0.0.13-7

4 years ago

0.0.13-6

4 years ago

0.0.13-5

4 years ago

0.0.13-4

4 years ago

0.0.13-0

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.11-10

4 years ago

0.0.11-2

4 years ago

0.0.11-4

4 years ago

0.0.11-3

4 years ago

0.0.11-1

4 years ago

0.0.11-0

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7-1

4 years ago

0.0.7-0

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.3-4

4 years ago

0.0.3-3

4 years ago

0.0.3-2

4 years ago

0.0.3-1

4 years ago

0.0.3-0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago