Skip to main content
When a payment is in the 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 transactionVersion parameter set to VERSION_2.
  • USDC in your sender wallet
  • (EVM chains only) Granted a USDC allowance to the Permit2 contract. 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:
After signing the payload, you should have an EIP-712 data signature in hex string format.

Solana

The transfer data to be signed is encoded in the encodedMessageToBeSigned 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.
If you are using the Circle Wallets, you can use the sign transaction endpoint to sign the transaction object.

Step 3: Submit the signed transaction

Call the submit transaction V2 endpoint to submit the signed transaction data to CPN. CPN broadcasts the transaction and provides a webhook to notify you of the transaction status. This webhook is also provided to the BFI. Once the BFI confirms that they have received the desired amount for the payment, the BFI initiates the fiat payment.

Handling failures

If a transaction fails and the payment is still valid (for example, it has not expired), you can address the issues with the transaction and initiate a new transaction. Because gas fees in native tokens are paid from a Circle-controlled wallet, insufficient gas is unlikely to be an issue. You can use a similar approach to address other onchain failures. Only one active transaction is allowed at a time per payment, so you can only initiate a new transaction once the previous one has failed.