• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Solidity
  • Created over 2 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NOTICE: This project eventually became the basis for Uniswap's Permit2, which supercedes this project in scope. Unless you need a really a lean/gas-optimized implementation provided by this solution, you'll probably want to use Permit2 👈

PermitEverywhere

PermitEverywhere is a set of contracts that enable permit style approvals for all ERC20 and ERC721 tokens, regardless of whether they implement EIP2612 or not.

Users simply need set an allowance on the ERC20PermitEverywhere contract (for ERC20 assets) or the ERC721PermitEverywhere contract (for ERC721 assets). Afterwards, protocols can accept a signed permit message from the user, which they can pass into a PermitEverywhere contract to securely transfer funds without an explicit allowance set on their own contracts.

Addresses

  • ERC20PermitEverywhere is deployed at 0xeee20efDe3b7222561CB29b03aa62d3f1368fba2 on Ethereum, Polygon, Optimism, Arbitrum, Rinkeby, and Ropsten.
  • ERC721PermitEverywhere is deployed at 0xEEe721c6f50d0223D4c19CA30Cf9F448E5B17426 on Ethereum, Polygon, Optimism, Arbitrum, Rinkeby, and Ropsten.
  • (ERC1155 coming soon).

Permit Messages

Permit messages are implemented EIP712 so they can be signed in a human readable fashion through popular web3 wallets.

ERC20PermitEverywhere Permit Spec

The EIP712Domain fields for ERC20PermitEverywhere messages are as follows:

    EIP712Domain({
        name: 'ERC20PermitEverywhere',
        version: '1.0.0',
        chainId: TARGET_CHAIN_ID,
        verifyingContract: 0xeee20efDe3b7222561CB29b03aa62d3f1368fba2
    })

The permit message itself is defined as:

struct PermitTransferFrom {
    // The token to transfer.
    address token;
    // Who can execute this permit.
    address spender;
    // Maximum amount of tokens to move.
    uint256 maxAmount;
    // Timestamp after which this permit is no longer valid.
    uint256 deadline;
    // The nonce for the signer of this permit.
    // The current nonce can be retrieved through ERC20PermitEverywhere.currentNonce().
    uint256 nonce;
}

ERC721PermitEverywhere Permit Spec

The EIP712Domain fields for ERC20PermitEverywhere messages are as follows:

    EIP712Domain({
        name: 'ERC721PermitEverywhere',
        version: '1.0.0',
        chainId: TARGET_CHAIN_ID,
        verifyingContract: 0xEEe721c6f50d0223D4c19CA30Cf9F448E5B17426
    })

The permit message itself is defined as:

struct PermitTransferFrom {
    // The token to transfer.
    address token;
    // Who can execute this permit.
    address spender;
    // The NFT token ID that can be moved. Ignored if allowAnyTokenId is true.
    uint256 tokenId;
    // If true, any token ID can be moved by spender.
    bool allowAnyTokenId;
    // Timestamp after which this permit is no longer valid.
    uint256 deadline;
    // The nonce for the signer of this permit.
    // The current nonce can be retrieved through ERC721PermitEverywhere.currentNonce().
    uint256 nonce;
}

Executing Permit Messages

For ERC20 permits, protocols can burn a user's permit message and execute an eligible transfer by calling ERC20PermitEverywhere.executePermitTransferFrom(), which is declared as follows:

    function executePermitTransferFrom(
        address from,
        address to,
        uint256 amount,
        PermitTransferFrom calldata permit,
        Signature calldata sig
    )
        external;

For ERC721 permits, protocols can burn a user's permit message and execute an eligible transfer by calling either ERC721PermitEverywhere.executePermitTransferFrom() or ERC721PermitEverywhere.executePermitSafeTransferFrom(), which are declared as follows:

    function executePermitTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        PermitTransferFrom calldata permit,
        Signature calldata sig
    )
        external
    function executePermitSafeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data,
        PermitTransferFrom calldata permit,
        Signature calldata sig
    )
        external;

More Repositories

1

zipped-contracts

Solidity
193
star
2

solpp

A solidity preprocessor and flattener CLI and library
JavaScript
112
star
3

eth-call-tracer

TypeScript
45
star
4

honeypause

Permissionless onchain exploit bounties tied to a circuit breaker
Solidity
39
star
5

send-tokens

Simple CLI tool to send ERC20 tokens with a private key, mnemonic, or keystore.
JavaScript
30
star
6

flex-contract

A modern, flexible Ethereum smart contract abstraction.
JavaScript
26
star
7

flex-ether

A modern, flexible library for sending ethereum transactions.
JavaScript
22
star
8

ez-ens

Simple, zero configuration Ethereum Name Service resolver.
JavaScript
18
star
9

pocketfurc

Text-only alternative client for the MMOSG Furcadia, written as a Chrome app. [ARCHIVED]
JavaScript
9
star
10

send-ether

Simple CLI tool to send Ethereum ether with a private key, mnemonic, or keystore.
JavaScript
8
star
11

create-web3-provider

Easily create a web3 provider from scratch
JavaScript
7
star
12

bytecode-zip-fe

bytecode.zip frontend
Svelte
5
star
13

find-token-deploys

search blocks backwards for possible ERC20 token deployments
JavaScript
5
star
14

eco-wallets

Ephemeral Counterfactual Wallets
Solidity
5
star
15

mooncatsrescue-subgraph

Subgraph for Mooncats Rescue
TypeScript
4
star
16

memory-linked-list

Space-efficient, in-memory, doubly linked lists for solidity
Solidity
3
star
17

vanity-search

Python
3
star
18

bn-str-256

Simple, functional big number library for up to 256-bit (32-byte) numbers that outputs decimal strings, with hex, binary, octal, and Buffer decoding/encoding.
JavaScript
3
star
19

erc721f

Solidity
2
star
20

honeypause-fe

TypeScript
2
star
21

wacom-profile-daemon

A tool for automatically switching graphics tablet options and area mapping based on the active window for X Desktops.
Python
2
star
22

red-paperclip-escrow

Solidity
1
star
23

uniswap-v3-test

JavaScript
1
star
24

native-eth-encoder

C++
1
star
25

upcity-contracts

Ethereum Smart Contracts for upcity.app
JavaScript
1
star