Skip to main content

Installation

Complete setup guide for the AGIRAILS SDK.

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)
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
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
import { ACTPClient } from '@agirails/sdk';
import { ethers, formatEther, formatUnits } from 'ethers';
import 'dotenv/config';

async function verify() {
const client = await ACTPClient.create({
network: 'base-sepolia',
privateKey: process.env.PRIVATE_KEY!
});

const address = await client.getAddress();
const config = client.getNetworkConfig();
const provider = client.getProvider();

// Check balances
const ethBalance = await provider.getBalance(address);
const usdcContract = new ethers.Contract(
config.contracts.usdc,
['function balanceOf(address) view returns (uint256)'],
provider
);
const usdcBalance = await usdcContract.balanceOf(address);

console.log('āœ“ Wallet:', address);
console.log('āœ“ Network: Base Sepolia');
console.log('āœ“ ACTPKernel:', config.contracts.actpKernel);
console.log('āœ“ EscrowVault:', config.contracts.escrowVault);
console.log('āœ“ ETH balance:', formatEther(ethBalance), 'ETH');
console.log('āœ“ USDC balance:', formatUnits(usdcBalance, 6), '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
āœ“ ACTPKernel: 0x6aDB650e185b0ee77981AC5279271f0Fa6CFe7ba
āœ“ EscrowVault: 0x921edE340770db5DB6059B5B866be987d1b7311F
āœ“ ETH balance: 0.1 ETH
āœ“ USDC balance: 1000.0 USDC

āœ… Setup verified!

Network Configuration​

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 network: 'base-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)

SDK Initialization Options​

import { ACTPClient } from '@agirails/sdk';

// Minimal (uses defaults)
const client = await ACTPClient.create({
network: 'base-sepolia',
privateKey: process.env.PRIVATE_KEY!
});

// With custom RPC
const client = await ACTPClient.create({
network: 'base-sepolia',
privateKey: process.env.PRIVATE_KEY!,
rpcUrl: 'https://base-sepolia.g.alchemy.com/v2/YOUR_KEY'
});

// With external signer (e.g., from wallet connection)
const client = await ACTPClient.create({
network: 'base-sepolia',
signer: externalSigner // ethers.Signer from wallet
});
Read-Only Mode Not Supported in V1

The SDK currently requires a signer for initialization. True read-only access (for querying transaction state without a private key) is planned for a future release. For now, use a throwaway private key if you only need to read data.


Next Steps​

šŸš€ Start Building

šŸ“š Learn More


Need help? Join our Discord