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:Note: The USDC token has 6 decimals. To approve $100 USDC, set
If you are following the Circle Wallets example, you will also need to add the following variables:APPROVAL_AMOUNTto100000000(100 × 10^6).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.
Steps
The following steps show how to grant a USDC token allowance to thePermit2
contract using a Circle Wallets developer-controlled wallet or an EIP-1193
Ethereum wallet.
Step 1. 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 (e.g.ETH,ETH-SEPOLIA,MATIC,MATIC-AMOY, etc.). If your Circle Wallet is on the genericEVM/EVM-TESTNETchain, 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.