Skip to main content

Overview

Every Chainrails transaction follows three simple steps from setup to completion:

Request a Quote

Define the parameters for the transaction (the intent) — amount, source chain, source token, destination chain, recipient, and refund address. This tells Chainrails what the user wants to send and where it’s going.

Generate an Intent Address

Once the quote is confirmed, Chainrails creates a unique intent address for that transaction. Think of this as a one-time deposit address that tracks and processes the transfer logic automatically.

Fund the Intent

The user then funds this intent address directly from their wallet. Once funded, Chainrails takes care of the rest — executing the cross-chain transfer, routing liquidity, and confirming settlement. The SDK abstracts most of these steps, so you can integrate this entire flow in just a few lines of code. In this Quickstart, we’ll walk you through how to get up and running in minutes.

Get started in three steps

1

Installation

Begin by installing the Chainrails SDK.
npm install @chainrails/sdk
2

Obtain your API Key

Send us a message at [email protected] to get an API Key or create one from the dashboard. This key will be used to authenticate your requests.
3

Initialize the Payment Modal

Import and initialize the Chainrails payment modal in your application.
import { chains, tokens, PaymentModal, usePaymentModal, Chainrails } from "@chainrails/react"

Chainrails.config({ api_key: <ENTER_API_KEY> })

function App() {
  const cr = usePaymentModal({
    to: "0x4F41BCf288E718A36c1e6919c2Dfc2E07d51c675",
    chain: chains.BASE,
    token: tokens.USDC,
    onCancel: () => {
      console.log("Payment Cancelled")
    },
    onSuccess: () => {
      console.log("Payment Successful")
    },
  })

  return (
    <div>
      <button onClick={cr.open}> Open Modal </button>
      {/* Pass 'amount' here to set a fixed amount.
        If you remove the amount prop, the user can input their own.
      */}
      <PaymentModal {...cr} amount={1}/>
    </div>
  )
}
Where:
  • to: Your wallet address to receive payments/deposits.
  • chain: The blockchain network to receive payments to.
  • token: The token/currency you want to receive.
  • amount: The amount to be paid/deposited. Leave empty or set to 0 to allow user input.
And voila! You are now ready to accept your first payment.

Demo

Check out our demo application to see Chainrails in action.