Protocol SDK for ACTP (Agent Commerce Transaction Protocol)
npm install @agirails/sdk
# or
yarn add @agirails/sdkimport { ACTPClient, State } from '@agirails/sdk';
import { ethers } from 'ethers';
// Initialize client (async factory pattern ensures EIP-712 domain is ready)
const client = await ACTPClient.create({
network: 'base-sepolia',
privateKey: process.env.PRIVATE_KEY
});
// Create transaction
const txId = await client.kernel.createTransaction({
provider: '0xProviderAddress...',
requester: await client.getAddress(),
amount: ethers.utils.parseUnits('100', 6), // 100 USDC
deadline: Math.floor(Date.now() / 1000) + 86400, // 24 hours
disputeWindow: 3600 // 1 hour
});
console.log(`Transaction created: ${txId}`);
// Watch transaction
client.events.watchTransaction(txId, (state) => {
console.log(`State changed to: ${State[state]}`);
});
// Get transaction
const tx = await client.kernel.getTransaction(txId);
console.log('Transaction:', tx);- ✅ Protocol SDK - Direct blockchain interaction with ACTP Kernel
- ✅ State Machine - Full ACTP state validation (8 states)
- ✅ Event Monitoring - Real-time blockchain event listening
- ✅ Message Signing - Cryptographic signing per Yellow Paper §11.4
- ✅ Proof Generation - Content hashing & delivery proofs
- ✅ TypeScript - Full type safety
- ✅ Base L2 - Optimized for Base Sepolia & Mainnet
The V1 ACTPKernel accepts attestation UIDs without on-chain validation. All verification (existence, schema, txId, revocation, expiry) is performed by SDK helpers like releaseEscrowWithVerification().
Security checks performed by SDK:
- Attestation exists and UID matches
- Schema UID matches canonical delivery schema (
0x1b0e...ffce) - txId in attestation matches expected transaction
- Attestation is not revoked (
revocationTime === 0) - Attestation has not expired
Integrators who bypass the SDK must implement equivalent verification logic.
EAS does not enforce uniqueness - multiple attestations can exist for the same txId. The SDK uses the first valid (non-revoked) attestation provided. This policy is testnet-appropriate; V2 will enforce uniqueness at the protocol level.
V2 will move critical verification on-chain. Until then, use only on Base Sepolia testnet with testnet USDC.
| Area | Limitation | Workaround |
|---|---|---|
| Network Resilience | No automatic retry | Manual retry required |
| Timeout Handling | tx.wait() may hang |
Set custom timeout |
| State Transitions | TOCTOU race condition | Contract provides final validation |
| Revocation Window | Attestation can be revoked between verify and settle | Use releaseEscrowWithVerification() |
For detailed documentation, visit the GitHub repository.
V2.0 Planned: On-chain attestation validation, uniqueness enforcement, multi-provider fallback
- Base Sepolia (testnet) -
chainId: 84532 - Base Mainnet -
chainId: 8453
For full documentation, examples, and specifications, visit the GitHub repository.
# Install dependencies
npm install
# Build
npm run build
# Unit tests (Jest - fast, no network)
npm test
# Integration tests (Hardhat - requires Base Sepolia RPC)
npm run test:integration
# Lint
npm run lintIntegration tests run against deployed contracts on Base Sepolia testnet:
Prerequisites:
-
Create
.envfile:BASE_SEPOLIA_RPC=https://sepolia.base.org # or your Alchemy URL PRIVATE_KEY=0x... # Account with Base Sepolia ETH for gas
-
Get testnet ETH:
Run tests:
npx hardhat test --network base-sepoliaTests will:
- ✅ Connect to deployed ACTPKernel, EscrowVault, MockUSDC
- ✅ Mint test USDC (MockUSDC has open minting on testnet)
- ✅ Run full transaction lifecycle (INITIATED → SETTLED)
- ✅ Verify escrow release and fund transfers
- ACTPKernel:
0x6aDB650e185b0ee77981AC5279271f0Fa6CFe7ba(view) - EscrowVault:
0x921edE340770db5DB6059B5B866be987d1b7311F(view) - MockUSDC:
0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb(view) - EAS Contract:
0x4200000000000000000000000000000000000021(Base native) - EAS Schema Registry:
0x4200000000000000000000000000000000000020(Base native) - Delivery Schema UID:
0x1b0ebdf0bd20c28ec9d5362571ce8715a55f46e81c3de2f9b0d8e1b95fb5ffce
Redeployed: 2025-11-25 | Fixed auto-transition in linkEscrow, optimizer-runs 200 | Matches src/config/networks.ts
- ACTPKernel: TBD (pending mainnet deployment)
- EscrowVault: TBD (pending mainnet deployment)
- USDC:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913(official USDC on Base)
Apache-2.0
- Email: developers@agirails.io
- GitHub: github.com/agirails/sdk-js