Installation
Install the Axon TypeScript SDK and configure your project.
Installation
The @axonfi/sdk package provides a typed client for signing payment intents and interacting with the Axon relay network. It works in Node.js 20+ and any modern bundler environment.
Install
# npm
npm install @axonfi/sdk
# yarn
yarn add @axonfi/sdk
# pnpm
pnpm add @axonfi/sdkPeer Dependency
The SDK requires viem v2 or later as a peer dependency. If you do not already have it installed:
npm install viem@^2.0.0viem is used internally for ABI encoding, EIP-712 typed data signing, and address utilities. It is listed as a peer dependency so your project controls the exact version and avoids duplicate bundles.
Module Format
The package ships as both ESM and CJS with full TypeScript declaration files. No additional @types package is needed.
- ESM —
import { AxonClient } from "@axonfi/sdk" - CJS —
const { AxonClient } = require("@axonfi/sdk")
Basic Setup
Option 1: Encrypted Keystore (Recommended)
If you downloaded an encrypted keystore file from the dashboard, decrypt it at startup:
import { AxonClient, decryptKeystore, Chain } from '@axonfi/sdk';
import fs from 'fs';
const keystore = fs.readFileSync(process.env.AXON_BOT_KEYSTORE_PATH!, 'utf8');
const privateKey = await decryptKeystore(keystore, process.env.AXON_BOT_PASSPHRASE!);
const axon = new AxonClient({
vaultAddress: '0xYourVaultAddress',
chainId: Chain.Base,
botPrivateKey: privateKey,
});
console.log('Bot address:', axon.botAddress);Option 2: Plain Private Key (Not Recommended)
import { AxonClient, Chain, USDC } from '@axonfi/sdk';
const axon = new AxonClient({
vaultAddress: '0xYourVaultAddress',
chainId: Chain.Base,
botPrivateKey: process.env.AXON_BOT_PRIVATE_KEY as `0x${string}`,
});The keystore file uses the standard Ethereum V3 format (scrypt + AES-128-CTR), same as MetaMask and Geth. It is safe to store in cloud backups or password managers — useless without the passphrase.
Never hardcode your bot private key in source code. Use environment variables or a secrets manager. The key is used only to sign EIP-712 intents locally and never leaves your process.
Environment Variables
A recommended .env file for local development:
# Option 1: Encrypted keystore (recommended)
AXON_BOT_KEYSTORE_PATH=./axon-bot-0xABCD1234.json
AXON_BOT_PASSPHRASE=<your-passphrase>
# Option 2: Plain private key (not recommended)
# AXON_BOT_PRIVATE_KEY=0x...
AXON_VAULT_ADDRESS=0x...
AXON_CHAIN_ID=84532USDC Addresses
The SDK exports a USDC constant mapping chain IDs to canonical USDC contract addresses:
import { USDC } from '@axonfi/sdk';
USDC[8453]; // 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (Base)
USDC[42161]; // 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 (Arbitrum)
USDC[84532]; // 0x036CbD53842c5426634e7929541eC2318f3dCF7e (Base Sepolia)Next Steps
- AxonClient Reference — full API for the client class
- Signing Helpers — low-level EIP-712 signing utilities
- Quickstart — send your first payment in under five minutes