Permit2
contract to enable allowance management. To get the benefits of Transactions V2,
you must grant a USDC token allowance to the Permit2 contract.
This guide shows two examples of how to grant a USDC token allowance to the
Permit2 contract. The
Permit2 documentation
provides additional examples of how to grant this allowance.
Prerequisites
The examples on this page show how to grant a USDC token allowance to thePermit2 contract using a
Circle Wallets developer-controlled wallet or a
generic EIP-1193 Ethereum wallet. Before you begin, ensure you have:
-
If you are following the Circle Wallets example:
- A Circle Developer Account
- A developer-controlled wallet
- Node.js and npm installed on your development machine
- A project set up as described in the below section
Set up your project
-
Initialize a new Node.js project and install dependencies:
-
In the project root, create a
.envfile and add the following variables:ThePERMIT2_CONTRACT_ADDRESSis the same across all EVM blockchains (0x000000000022D473030F116dDEE9F6B43aC78BA3), but you should verify it with the blockchain explorer on the chain you are using. You can find theUSDC_CONTRACT_ADDRESSon the USDC contract address page.If you are following the Circle Wallets example, you will also need to add the following variables:The USDC token has 6 decimals. To approve $100 USDC, setAPPROVAL_AMOUNTto100000000(100 * 106).If you are following the EIP-1193 Ethereum wallet example, or your Circle Wallet is on the genericEVM/EVM-TESTNETchain, you will also need to add the following variable: -
Create an
index.jsfile. You’ll add code step by step in the following sections.
Grant a USDC token allowance to the Permit2 contract
The following example code shows the process for granting a USDC token allowance
to the
Permit2 contract
using a Circle Wallets developer-controlled wallet or an EIP-1193 Ethereum
wallet.
- Circle Wallets
- Circle Wallets (generic EVM)
- EIP-1193 Ethereum Wallet
Note: This example is for a Circle Wallets developer-controlled wallet on
specific EVM blockchains (for example,
ETH, ETH-SEPOLIA, MATIC,
MATIC-AMOY, etc.). If your Circle Wallet is on the generic EVM /
EVM-TESTNET chain, which is likely the case if you are migrating from
Transactions V1 to V2, you can use the example in the “Circle Wallets (generic
EVM)” tab.