Skip to main content
You need an API Key to use the Chainrails SDK. You can get one by signing up on our dashboard or contacting us at contact@horuslabs.co.

Overview

Chainrails provides client SDKs for web and mobile applications:
  • @chainrails/sdk: Core TypeScript SDK for interacting with the Chainrails API
  • @chainrails/react: React components and hooks for web integrations
  • @chainrails/react-native: React Native components and hooks for mobile integrations
Together, these packages handle authentication, request formatting, UI integration, and error handling so you can focus on building your application.

Installation

npm install @chainrails/sdk

SDK Modules

The SDK is organized into the following modules:

Intents

Create and manage cross-chain transfer intents, track payment status, and retrieve intent information.

Router

Find optimal routes and analyze bridge availability for cross-chain transfers.

Quotes

Get real-time quotes for cross-chain transfers from various bridge providers.

Chains

Retrieve information about supported blockchain networks and tokens.

Client

Retrieve authenticated client information.

Platform Support

Chainrails SDK support is currently available for TypeScript/JavaScript, with UI integrations for React web and React Native.
  • Use @chainrails/sdk for server-side integrations and direct API access from TypeScript/JavaScript
  • Use @chainrails/react for web apps that need the Payment Modal and session hooks
  • Use @chainrails/react-native for React Native apps that need mobile payment flows

Authentication

The SDK uses API key-based authentication. Configure your API key once at startup:
import { Chainrails } from "@chainrails/sdk"

Chainrails.config({
  api_key: process.env.CHAINRAILS_API_KEY
})
The API key is automatically included in all requests via the Authorization: Bearer header.

Error Handling

The SDK throws errors for failed requests. Wrap SDK calls in try-catch blocks:
try {
  const intent = await crapi.intents.create({...})
} catch (error) {
  if (error instanceof Error) {
    console.error("Failed to create intent:", error.message)
  }
}

Type Definitions

The SDK includes full TypeScript type definitions for all requests and responses, providing autocomplete and type safety in your IDE.

Additional Notes

  1. Live API keys cannot be used with test networks. In test environments you can use supported mainnets and testnets, but live API keys must use mainnet networks only.
  2. Testnets also do not have indexing support. In modal flows, users must click I have made payment after funding on testnets. In API-driven flows, use POST /api/v1/intents/{intent_address}/trigger-processing to process the intent manually.