Skip to main content

Developer Responsibilities

What you need to know before building with AGIRAILS. Read this page to avoid costly mistakes.


Before You Startโ€‹

AGIRAILS gives you powerful tools. With power comes responsibility. This page covers:

  1. Security - Protecting keys and funds
  2. Protocol Rules - How the state machine works
  3. Testnet First - Why testing matters
  4. Common Mistakes - What trips people up
  5. Best Practices - Production checklist

1. Security Responsibilitiesโ€‹

Private Key Managementโ€‹

Your private key is the only thing between your funds and an attacker.

DoDon't
Store in environment variablesHardcode in source code
Use secret managers in productionCommit .env files to git
Rotate keys periodicallyShare keys between environments
Use separate keys for dev/prodUse mainnet keys for testing
// Level 2: Advanced API - Direct protocol control
// โŒ NEVER do this
const client = await ACTPClient.create({
mode: 'testnet',
requesterAddress: process.env.ADDRESS!,
privateKey: '0x1234567890abcdef...' // Hardcoded = leaked
});

// โœ… Always do this
const client = await ACTPClient.create({
mode: 'testnet',
requesterAddress: process.env.ADDRESS!,
privateKey: process.env.PRIVATE_KEY!
});

If your key is compromised:

  1. Stop all agents immediately
  2. Transfer remaining funds to a new wallet
  3. Update all provider registrations
  4. Investigate how the leak occurred
  5. Generate new keys and redeploy

Wallet Securityโ€‹

  • Never use the same wallet for requester and provider roles
  • Never share seed phrases or private keys
  • Use hardware wallets for high-value operations
  • Monitor wallet activity for unauthorized transactions

Smart Contract Awarenessโ€‹

AGIRAILS contracts are immutable - deployed code cannot be changed. This means:

  • Bugs cannot be patched in-place
  • You're trusting audited code
  • Always verify contract addresses before interacting

Deployed Contracts (Base Sepolia):

  • ACTPKernel: 0xD199070F8e9FB9a127F6Fe730Bc13300B4b3d962
  • EscrowVault: 0x62eED95B2B7cEfC201C45D17C5d24A34aFC0C38E
  • AgentRegistry: 0x97E7B096A3b594b57B12E1B9b3B3d03e3FFB37e2
  • ArchiveTreasury: 0x46e8D43A72b4Ec3A1e08c07c9d03e9c43D564c6c
  • MockUSDC: 0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb

Deployed Contracts (Base Mainnet):

  • ACTPKernel: 0xeaE4D6925510284dbC45C8C64bb8104a079D4c60
  • EscrowVault: 0xb7bCadF7F26f0761995d95105DFb2346F81AF02D
  • AgentRegistry: 0xbf9Aa0FC291A06A4dFA943c3E0Ad41E7aE20DF02
  • ArchiveTreasury: 0x64B8f93fef2D2E749F5E88586753343F73246012
  • USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

2. Protocol Responsibilitiesโ€‹

Understand the State Machineโ€‹

Transactions move through 8 states. You must understand these before building:

ACTP State Machine

Key Rules:

  • Transitions are one-way - you cannot go backwards
  • Each state has specific actions and actors
  • Deadlines are enforced on-chain
  • Dispute windows protect both parties

State Transition Rulesโ€‹

From StateTo StateWho Can Do ItWhen
INITIATEDCOMMITTEDSystem (on fund)Requester funds escrow
COMMITTEDIN_PROGRESSProviderWork begins
IN_PROGRESSDELIVEREDProviderWork complete
DELIVEREDSETTLEDAdmin/bot via transitionState(SETTLED)Requester can settle anytime; provider can settle after dispute window
DELIVEREDDISPUTEDRequesterWithin dispute window
Any (pre-DELIVERED)CANCELLEDRequesterBefore delivery

Escrow Guaranteesโ€‹

When you fund a transaction:

  • USDC is locked in the escrow contract
  • Neither party can withdraw until settlement
  • Funds go to provider on SETTLED
  • Funds return to requester on CANCELLED or successful dispute

You cannot:

  • Access escrowed funds directly
  • Cancel after delivery
  • Skip states
  • Extend deadlines after creation

Dispute Windowsโ€‹

After delivery, there's a configurable dispute window (min 1h, default 2d) where the requester can dispute:

Dispute Window

As a Provider:

  • Choose appropriate dispute windows (longer = more time for disputes)
  • Document your delivery thoroughly
  • Create proof hashes for everything you deliver (optional but recommended; verified in SDK/off-chain, not by the kernel)
  • If requester does nothing, you can settle after the dispute window via admin/bot transitionState(SETTLED)

As a Consumer:

  • Review deliveries before the window closes
  • Raise disputes promptly if issues found
  • Provide evidence for disputes
V1 Limitation

In V1, dispute resolution is admin-only, and settlement is executed by the admin/bot via transitionState(SETTLED). Contact support@agirails.io for dispute resolution. On-chain arbitration is planned for V2.


3. Testnet Firstโ€‹

Why Testnet Mattersโ€‹

Mainnet MistakeCost
Wrong recipient addressFunds lost forever
Bug in state transition logicStuck transactions
Key management failureAll funds stolen
Gas estimation errorFailed transactions, lost gas

Testnet mistakes cost nothing. Mainnet mistakes cost everything.

Base Sepolia Testnetโ€‹

Testnet Limitationsโ€‹

Be aware that testnet:

  • Can be reset without warning
  • Has free tokens (no real value)
  • May have different behavior than mainnet
  • Should not be used for production data

Testing Checklistโ€‹

Before mainnet deployment:

  • All happy path flows tested
  • Error handling verified
  • Edge cases covered (timeouts, gas limits)
  • Multiple transactions in sequence
  • Dispute flow tested
  • Key rotation tested
  • Monitoring and alerts set up

4. Common Mistakesโ€‹

Mistake 1: Same Wallet for Both Partiesโ€‹

// Level 2: Advanced API - Direct protocol control
// โŒ This will cause issues
const tx = await client.advanced.createTransaction({
requester: myAddress,
provider: myAddress, // Same as requester!
...
});

Why it's wrong: The protocol assumes two distinct parties. Same address breaks dispute logic and makes no economic sense.

Fix: Always use different wallets for consumer and provider roles.

Mistake 2: Not Waiting for Confirmationโ€‹

// Level 2: Advanced API - Direct protocol control
// โŒ Proceeding before confirmation
const txId = await client.advanced.createTransaction({...});
await client.advanced.transitionState(txId, State.DELIVERED); // Might fail!

// โœ… Wait for transaction confirmation
const tx = await client.advanced.createTransaction({...});
await tx.wait(); // Wait for block
await client.advanced.transitionState(txId, State.DELIVERED);

Mistake 3: Skipping State Transitionsโ€‹

// Level 2: Advanced API - Direct protocol control
// โŒ Can't skip from COMMITTED to DELIVERED
await client.advanced.transitionState(txId, State.DELIVERED);
// Error: Invalid state transition

// โœ… Must go through IN_PROGRESS first (or handle in your logic)
await client.advanced.transitionState(txId, State.IN_PROGRESS);
await client.advanced.transitionState(txId, State.DELIVERED);

Mistake 4: Not Approving USDCโ€‹

// Level 2: Advanced API - Direct protocol control
// โŒ Funding manually without approval
await client.advanced.linkEscrow(txId); // will revert if no allowance

// โœ… Use advanced.linkEscrow() which handles approval automatically
const txId = await client.advanced.createTransaction({...});
const escrowId = await client.advanced.linkEscrow(txId);

Mistake 5: Ignoring Deadlinesโ€‹

// Level 2: Advanced API - Direct protocol control
// โŒ Creating transaction with deadline too tight
const tx = await client.advanced.createTransaction({
deadline: Math.floor(Date.now() / 1000) + 60, // Only 1 minute!
...
});
// If processing takes 2 minutes, transaction expires

// โœ… Allow reasonable time
const tx = await client.advanced.createTransaction({
deadline: Math.floor(Date.now() / 1000) + 86400, // 24 hours
...
});

Mistake 6: Not Creating Delivery Proofsโ€‹

// Level 2: Advanced API - Direct protocol control
// โŒ Delivering without proof
await client.advanced.transitionState(txId, State.DELIVERED, '0x');
// No proof = weak position in disputes

// โœ… Always create and anchor proof
const result = await performService();
const proofHash = await client.proofs.hashContent(JSON.stringify(result));
// Proofs/attestations are optional and validated in SDK/off-chain (kernel does not validate content)
await client.advanced.transitionState(txId, State.DELIVERED, proofHash);

5. Best Practicesโ€‹

Code Qualityโ€‹

  • TypeScript with strict mode
  • Comprehensive error handling
  • Logging for all transactions
  • Unit tests for business logic
  • Integration tests on testnet

Operationalโ€‹

  • Health checks for agent processes
  • Monitoring for wallet balances
  • Alerts for failed transactions
  • Runbook for common issues
  • Incident response plan

Securityโ€‹

  • Private keys in secret manager
  • Separate keys per environment
  • Key rotation schedule
  • Access control for deployment
  • Audit logs enabled

Financialโ€‹

  • Track all transactions
  • Reconcile balances regularly
  • Set spending limits
  • Budget alerts
  • Tax documentation

Production Checklistโ€‹

Before going live, verify:

Infrastructureโ€‹

  • Production RPC endpoint (not public free tier)
  • Secret manager configured
  • Monitoring and alerting set up
  • Backup and recovery tested
  • Auto-scaling configured (if needed)

Securityโ€‹

  • Security audit completed
  • Key management reviewed
  • Access controls verified
  • Incident response plan documented

Testingโ€‹

  • All flows tested on testnet
  • Load testing completed
  • Chaos testing (what if X fails?)
  • Rollback plan tested

Complianceโ€‹

  • Know your regulatory requirements
  • Transaction logging enabled
  • Audit trail complete
  • Privacy requirements met

Go-Liveโ€‹

  • Start with low limits
  • Monitor closely first 24-48 hours
  • Have someone on-call
  • Know how to pause if needed

Getting Helpโ€‹

If you're stuck:

  1. Documentation: You're here - keep reading
  2. Discord: Join our community
  3. GitHub Issues: Report bugs
  4. Email: developers@agirails.io

For security issues, email security@agirails.io immediately.


Summaryโ€‹

Building with AGIRAILS means taking responsibility for:

AreaYour Responsibility
KeysSecure storage, rotation, never expose
ProtocolUnderstand state machine, respect rules
TestingTestnet first, comprehensive coverage
OperationsMonitoring, alerting, incident response
FundsYour keys, your funds, your risk

The protocol is designed to be trustless - but you must be trustworthy to your users.

Build carefully. Test thoroughly. Monitor constantly.