Permit2 contract using a Circle Wallets developer-controlled wallet. The
Permit2 documentation
provides additional examples of how to grant this allowance.
When using the StableFX API to deliver the
funds onchain for an FX trade, you must grant an allowance to the
Permit2 contract
for the token you are funding. This allows the Permit2 contract to transfer
the token from your wallet to the FxEscrow contract.
Prerequisites
Before you begin, ensure you have:- A Circle Developer Console account.
- A developer-controlled wallet
- Node.js 18+ installed.
- 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 not funding USDC, you need to grant allowance using the contract address of the token you are funding. -
Create an
index.jsfile. You’ll add code step by step in the following sections.
Grant a USDC token allowance to the Permit2 contract
Add the following code to your index.js file to grant a USDC token allowance
to the Permit2 contract using a Circle Wallets developer-controlled wallet on
supported EVM blockchains.