CRYPTO_FUNDS_PENDING state, the OFI must initiate an
onchain transaction to fulfill the payment in USDC. CPN provides an API to help
prepare and validate the onchain transaction call data, and to broadcast the
transaction and monitor its state.
This guide describes the
Transactions V2 flow. Note that
your quote must be created with the transactionVersion parameter set to
VERSION_2 to match the API that you’re using.
Prerequisites
Before you begin, ensure that you have:- Created a quote through the CPN API with the
transactionVersionparameter set toVERSION_2. - USDC in your sender wallet
- (EVM chains only) Granted a USDC allowance to the
Permit2contract. See How-to: Grant USDC Allowance to Permit2 for more information. - (Solana only) Ensure your Solana account has been initialized and funded.
Gas fees are not charged in native tokens, but in USDC. They are determined at
quote creation instead of transaction creation in the quote
fees field. The
gas fee is collected by Circle’s payment settlement smart contract during
onchain transaction processing.Steps
Use the following steps to create and broadcast a USDC transfer to the blockchain:Step 1: Prepare the call data
Call the create transaction V2 endpoint to get an unsigned message object. Note that transaction objects differ between EVM blockchains and Solana. The API call must include the sender wallet information (which must be an EOA wallet). The rest of the transaction data such as amount, chain, destination address, and other information is populated automatically by CPN using the payment record.Step 2: Create and sign the transaction
Review the unsigned message object and ensure that it matches your expectations for the crypto transaction. Depending on the blockchain, the signing process varies.EVM
When the unsigned data has been confirmed, you must sign the transaction payload from the API endpoint using EIP-712 typed data signing from your sender wallet. The following is an example payload:Solana
The transfer data to be signed is encoded in theencodedMessageToBeSigned
field from the
POST /v2/cpn/payments/:paymentId/transactions
endpoint. You would need to first decode it using the base64 library and then
sign it using a Solana library with your wallet key pair.