Skip to main content
Creates a new payment intent with cross-chain transfer parameters. Parameters:
  • sender (required): Sender wallet address on the source chain
  • amount (required): Amount to transfer in smallest unit (e.g., wei for ETH)
  • tokenIn (required): Token address on the source chain
  • source_chain (required): Source blockchain network
  • destination_chain (required): Destination blockchain network
  • recipient (required): Recipient wallet address on the destination chain
  • refund_address (optional): Refund address if intent fails (defaults to sender)
  • metadata (optional): Additional metadata for the intent
import { crapi, Chainrails } from "@chainrails/sdk"

Chainrails.config({
  api_key: "your_api_key_here"
})

const intent = await crapi.intents.create({
  sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  amount: "1000000",
  tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  source_chain: "ETHEREUM_MAINNET",
  destination_chain: "STARKNET_MAINNET",
  recipient: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
  refund_address: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
  metadata: {
    orderId: "12345",
    userId: "user-abc"
  }
})

console.log("Intent created:", intent)