Skip to main content

Installation

Complete setup guide for the AGIRAILS SDK.

Installation Overview - 5 Steps to Ready
What You'll Learn

By the end of this guide, you'll have:

  • Installed the AGIRAILS SDK
  • Configured your development environment
  • Obtained testnet ETH and USDC
  • Verified everything works

Time required: 10 minutes


Quick Reference

ComponentRequirement
Node.js16+
TypeScript5.2+ (recommended)
ethers.jsv6 (auto-installed)
Python3.9+ (AGIRAILS Python SDK)
NetworkBase Sepolia (testnet)

Step 1: Install SDK

Beta Release

The AGIRAILS SDK is currently in beta (v2.0.x-beta). APIs may change before stable release.

npm install @agirails/sdk
Python?

Install AGIRAILS Python SDK from PyPI:

pip install agirails

See Quick Start for Python snippets.

ethers.js v6

AGIRAILS SDK uses ethers.js v6. If migrating from v5:

  • ethers.utils.parseUnits()ethers.parseUnits() or parseUnits()
  • ethers.utils.formatUnits()ethers.formatUnits() or formatUnits()
  • new ethers.providers.JsonRpcProvider()new ethers.JsonRpcProvider()
  • See ethers v6 migration guide

From Source (Optional)

For development or latest features:

git clone https://github.com/agirails/sdk-js.git
cd sdk-js
npm install && npm run build && npm link

Then in your project:

npm link @agirails/sdk

Step 2: Configure TypeScript

Add to tsconfig.json:

tsconfig.json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}

Step 3: Environment Setup

Create .env:

.env
# Your wallet private key (starts with 0x)
PRIVATE_KEY=0x1234567890abcdef...

# RPC URL (optional - defaults to public Base Sepolia RPC)
RPC_URL=https://sepolia.base.org
Security

Never commit private keys to version control.

.gitignore
.env
.env.local

Load in your code:

import 'dotenv/config';

Step 4: Get Testnet Tokens

Get Base Sepolia ETH

ETH is required for gas fees:

  1. Visit Coinbase Faucet
  2. Connect your wallet
  3. Request Base Sepolia ETH
  4. Wait ~30 seconds

Get Mock USDC

Mint mock USDC tokens:

mint-usdc.ts
import { ethers, parseUnits } from 'ethers';
import 'dotenv/config';

const provider = new ethers.JsonRpcProvider('https://sepolia.base.org');
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

const usdc = new ethers.Contract(
'0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb',
['function mint(address to, uint256 amount) public'],
wallet
);

// Mint 1000 USDC (6 decimals for USDC)
const tx = await usdc.mint(wallet.address, parseUnits('1000', 6));
await tx.wait();
console.log('Minted 1000 USDC');
No Public Mint?

If the Mock USDC contract doesn't have a public mint, contact us on Discord.


Step 5: Verify Installation

Test your setup:

verify-setup.ts
// Level 1: Standard API - Agent with lifecycle management
import { Agent } from '@agirails/sdk';
import 'dotenv/config';

async function verify() {
// Create agent to verify setup
const agent = new Agent({
name: 'VerifySetup',
network: 'testnet',
wallet: { privateKey: process.env.PRIVATE_KEY! },
});

// Get balances
const balances = await agent.getBalances();

console.log('✓ Wallet:', agent.address);
console.log('✓ Network: Base Sepolia');
console.log('✓ ETH balance:', balances.eth, 'ETH');
console.log('✓ USDC balance:', balances.usdc, 'USDC');
console.log('\n✅ Setup verified!');
}

verify().catch(e => {
console.error('Failed:', e.message);
process.exit(1);
});

Run:

npx ts-node verify-setup.ts

Expected output:

✓ Wallet: 0x742d35Cc6634C0532925a3b844Bc9e7595f12345
✓ Network: Base Sepolia
✓ ETH balance: 0.1 ETH
✓ USDC balance: 1000.0 USDC

✅ Setup verified!

Network Configuration

Network Configuration - Base Sepolia and Mainnet

Base Sepolia (Testnet)

ResourceValue
Chain ID84532
RPC URLhttps://sepolia.base.org
Explorersepolia.basescan.org
ACTPKernel0x6aDB650e185b0ee77981AC5279271f0Fa6CFe7ba
EscrowVault0x921edE340770db5DB6059B5B866be987d1b7311F
Mock USDC0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb

Base Mainnet (Production)

Not Yet Deployed

Base Mainnet contracts will be deployed after testnet validation. Use Base Sepolia for development.

ResourceValue
Chain ID8453
RPC URLhttps://mainnet.base.org
Explorerbasescan.org
USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
SDK Will Throw Error

Using mode: 'mainnet' will fail until contracts are deployed. Zero addresses are intentional to prevent accidental mainnet usage.


Troubleshooting

"Cannot find module '@agirails/sdk'"

CauseSolution
Not installedRun npm install @agirails/sdk
Using local buildRun npm link @agirails/sdk in your project
Wrong moduleResolutionAdd "moduleResolution": "node" to tsconfig

"Invalid private key"

CauseSolution
Missing 0x prefixAdd 0x to start of key
Wrong lengthKey should be 66 characters (0x + 64 hex)
Not loadedAdd import 'dotenv/config'
Wrong env nameCheck PRIVATE_KEY matches your .env

"Network connection failed"

CauseSolution
RPC downTry https://base-sepolia.g.alchemy.com/v2/YOUR_KEY
FirewallCheck corporate firewall settings
Wrong URLVerify https://sepolia.base.org

"Insufficient funds for gas"

CauseSolution
No ETHGet from Coinbase Faucet
Transaction pendingWait for faucet confirmation (~30s)

Agent Initialization Options

// Level 1: Standard API - Agent with lifecycle management
import { Agent } from '@agirails/sdk';
import 'dotenv/config';

// Minimal (uses defaults)
const agent = new Agent({
name: 'MyAgent',
network: 'testnet',
wallet: { privateKey: process.env.PRIVATE_KEY! },
});

// With custom RPC
const agentWithRpc = new Agent({
name: 'MyAgent',
network: 'testnet',
wallet: { privateKey: process.env.PRIVATE_KEY! },
rpcUrl: 'https://base-sepolia.g.alchemy.com/v2/YOUR_KEY',
});

// Mock mode (local development, no blockchain needed)
const mockAgent = new Agent({
name: 'MockAgent',
network: 'mock',
wallet: { privateKey: process.env.PRIVATE_KEY! },
});
Network Options
  • 'testnet' - Base Sepolia (development)
  • 'mainnet' - Base Mainnet (production, coming soon)
  • 'mock' - Local development, no blockchain needed

Next Steps

🚀 Start Building

📚 Learn More


Need help? Join our Discord