Implement Chainrails payment flow from start to finish
This guide walks you through the complete payment lifecycle using Chainrails, from generating a payment intent, funding it, to confirming its success using the APIs.
Before creating a payment intent, you need to request for quotes to help the user understand the costs for the multiple cross-chain routes available.
We often recommend using the multi-source quote endpoint to get quotes from multiple source chains for a given destination chain. This fetches the best quotes for multiple source chains, providing more options for the user. See Multi-Source Quotes for more details.
But you can also request a single quote for a specific source chain, bridge option etc. if you decide to. See the Api Reference for all available quote endpoints.
Some quote endpoints take in an optional amountSymbol parameter which can be used to specify the denomination of the amount you want to send. For quotes in USD, you can either set amountSymbol to USDC (or leave it empty).You can quote in a different denomination than the token you want to send. For example, you can set amountSymbol to USDC, while sending ETH as tokenIn
Display the intent deposit address to the user on your payment screen.
The user should send the exact totalAmount from their wallet on the selected source chain.Once the funds are detected on-chain, the Chainrails protocol takes over.
Prefills the transaction on the destination chain for the end user
Refunds the relayer, who provided the liquidity to prefill the cross-chain execution, or
Refunds the user if the intent expired without initiating.
At this stage, you do not need to take any further action — the entire bridging and execution process is handled by the protocol.NB: You can however trigger the intent processing flow manually, if the indexer goes down for any reason or missed a transaction, using the POST /api/v1/intents/{intent_address}/trigger-processing endpoint.
Intent addresses are like one-off account numbers, they can’t be reused, so a new one is generated for every intent.
If the user under-funds the intent, the transaction will fail to start, and the user can either top up the balance of the intent address, or a refund will be processed after intent expiration.
If the user over-pays an intent, the excess is refunded on intent initiation.
API keys have a rate limit of 250 rps, contact the team if you need modifications to this.