Installation
Complete setup guide for the AGIRAILS SDK.
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ā
| Component | Requirement |
|---|---|
| Node.js | 16+ |
| TypeScript | 5.2+ (recommended) |
| ethers.js | v6 (auto-installed) |
| Network | Base Sepolia (testnet) |
Step 1: Install SDKā
The AGIRAILS SDK is currently in beta (v2.0.x-beta). APIs may change before stable release.
npm install @agirails/sdk
AGIRAILS SDK uses ethers.js v6. If migrating from v5:
ethers.utils.parseUnits()āethers.parseUnits()orparseUnits()ethers.utils.formatUnits()āethers.formatUnits()orformatUnits()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:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}
Step 3: Environment Setupā
Create .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
Never commit private keys to version control.
.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:
- Visit Coinbase Faucet
- Connect your wallet
- Request Base Sepolia ETH
- Wait ~30 seconds
Get Mock USDCā
Mint mock USDC tokens:
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');
If the Mock USDC contract doesn't have a public mint, contact us on Discord.
Step 5: Verify Installationā
Test your setup:
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)ā
| Resource | Value |
|---|---|
| Chain ID | 84532 |
| RPC URL | https://sepolia.base.org |
| Explorer | sepolia.basescan.org |
| ACTPKernel | 0x6aDB650e185b0ee77981AC5279271f0Fa6CFe7ba |
| EscrowVault | 0x921edE340770db5DB6059B5B866be987d1b7311F |
| Mock USDC | 0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb |
Base Mainnet (Production)ā
Base Mainnet contracts will be deployed after testnet validation. Use Base Sepolia for development.
| Resource | Value |
|---|---|
| Chain ID | 8453 |
| RPC URL | https://mainnet.base.org |
| Explorer | basescan.org |
| USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
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'"ā
| Cause | Solution |
|---|---|
| Not installed | Run npm install @agirails/sdk |
| Using local build | Run npm link @agirails/sdk in your project |
| Wrong moduleResolution | Add "moduleResolution": "node" to tsconfig |
"Invalid private key"ā
| Cause | Solution |
|---|---|
Missing 0x prefix | Add 0x to start of key |
| Wrong length | Key should be 66 characters (0x + 64 hex) |
| Not loaded | Add import 'dotenv/config' |
| Wrong env name | Check PRIVATE_KEY matches your .env |
"Network connection failed"ā
| Cause | Solution |
|---|---|
| RPC down | Try https://base-sepolia.g.alchemy.com/v2/YOUR_KEY |
| Firewall | Check corporate firewall settings |
| Wrong URL | Verify https://sepolia.base.org |
"Insufficient funds for gas"ā
| Cause | Solution |
|---|---|
| No ETH | Get from Coinbase Faucet |
| Transaction pending | Wait 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
});
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
- Quick Start - First transaction
- Provider Agent - Get paid
- Consumer Agent - Request services
š Learn More
- Core Concepts - How AGIRAILS works
- SDK Reference - Full API docs
- Contract Reference - On-chain API
Need help? Join our Discord