- Circle Wallets
- Self-managed
Use Then, update the Run the script:
@circle-fin/developer-controlled-wallets to fund an Arc Testnet EOA and
@circle-fin/x402-batching to pay for an x402-protected resource. Smart
contract account (SCA) wallets are not supported for nanopayments because
Gateway verifies the EIP-3009 authorization with ecrecover. For more
information, see Account types.Prerequisites
Before you begin, ensure that you’ve:- Installed Node.js v22.6+.
- Created a Circle Console account.
- Created an API key in the Circle Console.
- Generated and registered an Entity Secret.
- Created an EOA developer-controlled wallet on Arc Testnet.
pay.ts.Step 1. Set up your project
1.1. Create the project and install dependencies
1.2. Configure TypeScript (optional)
Create atsconfig.json file:tsconfig.json file:1.3. Set environment variables
Open.env in your editor and add:.env
CIRCLE_API_KEYis your Circle API key.CIRCLE_ENTITY_SECRETis your Circle entity secret.
Step 2. Initialize the Circle Wallets client
Createpay.ts and replace the wallet address placeholder with the address from
the developer-controlled wallet quickstart. Copy this block into pay.ts first.pay.ts
BatchEvmScheme builds the EIP-3009 payment authorization. The callback
normalizes its viem-style typed data for Circle Wallets by adding the explicit
EIP712Domain type, serializing chainId, and converting the response to a
0x-prefixed signature. The developer-controlled wallet signs the authorization
without exposing a private key to this script.Step 3. Fund the wallet
Use the Circle Faucet to send testnet USDC to the Arc Testnet wallet address from the wallet quickstart. Arc Testnet uses USDC as its native gas token, so the faucet funds both the USDC deposit and the transaction fees.Step 4. Deposit USDC into Gateway
Before making a nanopayment, the wallet needs USDC in its Gateway balance. The following function:- Checks the current Gateway balance.
- Approves the Gateway Wallet contract to spend USDC.
- Deposits USDC into Gateway.
- Waits until the deposited balance is available.
pay.ts. They are standalone declarations, so copy them
as-is below the initialization code.pay.ts
Step 5. Pay for a resource
The first request to an x402-protected endpoint returns402 Payment Required
and a PAYMENT-REQUIRED header. Sellers often advertise Gateway options for
many blockchains. Select the Arc Testnet GatewayWalletBatched option so the
EIP-712 chainId matches the Circle Wallets ARC-TESTNET signer, then create
the authorization and retry with a PAYMENT-SIGNATURE that includes the chosen
option and the resource metadata from the 402 response.Add payForResource to pay.ts:pay.ts
Step 6. Run the script
At the end ofpay.ts, add a small entry point that calls the functions in
order:pay.ts
The seller returns the resource as soon as Gateway accepts the payment.
Onchain settlement happens later when Gateway includes the payment in a
batch (often several
minutes). You do not need to wait for that to complete a successful pay. To
inspect status later, query Search x402
Transfers with the EIP-3009
authorization nonce.