Skip to content

๐Ÿ”‘๐Ÿ”‘๐Ÿ”‘ next generation token approvals mechanism

License

Notifications You must be signed in to change notification settings

doublespending/permit2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

permit2

Permit2 introduces a low-overhead, next generation token approval/meta-tx system.

Features

  • Signature Based Approvals: Any ERC20 token, even those that do not support EIP-2612, can now use permit style approvals.
  • Batched Token Approvals: Set permissions on different tokens to different spenders with one signature.
  • Signature Based Token Transfers: Owners can sign messages to transfer tokens directly to signed spenders.
  • Batched Token Transfers: Transfer different tokens to different recipients with one signature.
  • Safe Arbitrary Data Verification: Verify any extra data by passing through a witness hash and witness type.
  • Signature Verification for Contracts: All signature verification supports EIP-1271 so contracts can approve tokens and transfer tokens through signatures.
  • Non-monotonic Replay Protection: Signature based transfers use unordered, non-monotonic nonces so that signed permits do not need to be transacted in any particular order.

Architecture

Permit2 is the union of two contracts: AllowanceTransfer and SignatureTransfer. These contracts handle signature based allowances of tokens and signature based transfers of tokens, respectively.

Contributing

You will need a copy of Foundry installed before proceeding. See the installation guide for details.

Setup

git clone https://github.com/Uniswap/permit2.git
cd permit2
forge install

Lint

forge fmt [--check]

Run Tests

# unit
forge test

# integration
source .env
FOUNDRY_PROFILE=integration forge test

Update Gas Snapshots

forge snapshot

Deploy

Run the command below. Remove --broadcast, ---rpc-url, --private-key and --verify options to test locally

forge script --broadcast --rpc-url <RPC-URL> --private-key <PRIVATE_KEY> --verify script/DeployPermit2.s.sol:DeployPermit2

Acknowledgments

Inspired by merklejerk's permit-everywhere contracts which introduce permit based approvals for all tokens regardless of EIP2612 support.

About

๐Ÿ”‘๐Ÿ”‘๐Ÿ”‘ next generation token approvals mechanism

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 96.8%
  • Julia 3.2%