getwax / bls-wallet

Core components to use layer 2 smart contract wallets with the BLS signature scheme
MIT License
178 stars 47 forks source link

ERC20 expander #577

Closed voltrevo closed 1 year ago

voltrevo commented 1 year ago

What is this PR doing?

(Also includes fixes for bls-wallet-clients... guessing there was a bad merge involved previously.)

Adds ERC20 expander that encodes transfers in about 20 bytes plus:

Supports multiple actions and the other ERC20 methods (approve, transferFrom, mint).

Example:

0f      - 0x0f = 0b1111 bit stream:
          - 1: Use registry for BLS key
          - 1: Include a tx.origin payment
          - 1: Use registry for ERC20 address
          - 1: Use registry for recipient address
000000  - Registry index for sendWallet's public key
00      - nonce: 0
0bda28  - gas: 92,483
02      - two actions
000000  - Registry index for ERC20 address
00      - transfer
000002  - Registry index for recipient address
9100    - 0.1 MCK (amount/value)
6d00    - Pay 0.000005 ETH to tx.origin

Improvements that could be made for super-optimized transfers:

This would get us down to about 11 bytes.

How can these changes be manually tested?

yarn test

Does this PR resolve or contribute to any issues?

Resolves #576

Checklist

Guidelines