AgentRail is a protocol layer that lets agents discover, reason about, and execute onchain actions through structured JSON.
The protocol is generic. It is designed to work across EVM contracts and DeFi protocols, not just one integration. Aave-specific methods in this repo are examples of higher-level adapters built on top of the same core protocol surface.
The goal is simple:
- make onchain actions easier for agents to discover
- make common tasks safer by default
- reduce the amount of ABI / RPC / glue logic an agent has to invent
- return outputs that are small, structured, and easy for models to use
Most onchain tooling is built for developers:
- SDKs expect you to know the ABI
- contract calls return raw values, not task-level meaning
- every agent has to rediscover the same steps: find contract -> resolve ABI -> read decimals -> format balance -> simulate -> send -> decode receipt
AgentRail packages that into a protocol surface designed for agents.
Instead of only offering low-level primitives like readContract, it also offers:
registry.lookuptoken.balanceprotocol-specific adaptersaction.planreceipt.decode
Compared with raw contract-call primitives, this protocol adds:
-
ABI flexibility It can use a provided ABI,
abiPath, explorer/Sourcify discovery, built-in standards, or a minimal function signature plusreturns. -
Higher-level methods Agents can ask for
token.balance, protocol adapters, or planning methods instead of stitching together multiple raw reads. -
Safer write flows
simulate-first, signer guards, policy checks, and explicit error advice are built into the protocol surface. -
Agent-friendly outputs Responses can include
formatted,summary,highlights,bestMatch, andeffects, not just raw onchain values. -
Self-description The protocol exposes
rpc.discover,--llms, and per-methodschemaoutput. -
Token-efficient responses CLI and protocol-level output filtering support smaller responses for LLM runtimes.
No.
AgentRail is a protocol layer that can sit on top of existing SDKs, clients, and RPC infrastructure.
It is designed for agent workflows, structured outputs, and safer task-level operations rather than replacing lower-level tools.
No. Aave is the first high-level adapter in the repo today, but the protocol itself is generic. It already supports generic contract reads, simulation, transaction building, sending, and receipt decoding for arbitrary EVM contracts.
Not always.
You can provide a full ABI, an abiPath, rely on ABI discovery, or use minimal function-signature mode with returns.
Safer than handing an agent a raw SDK by default, but still sensitive.
AgentRail is built around explicit callers, simulation-first flows, policy checks, and signer isolation.
You should still use dedicated wallets, limits, and allowlists in real deployments.
At a high level, AgentRail gives agents three layers of capability:
- generic contract access
- safer transaction execution
- optional protocol-specific adapters for common workflows
Core contract methods:
contract.inspectcontract.functionscontract.describecontract.readbatch.readcontract.simulatetx.buildtx.sendreceipt.decode
Built-in higher-level methods and adapters today:
registry.lookuptoken.balanceaave.positionsaction.plan
aave.positions is an example adapter, not the boundary of the protocol.
AgentRail's core contract methods are intended to work across any EVM-based DeFi protocol as long as the contract is reachable and the ABI can be provided or discovered.
-
Aliases
lookup,tokenBalance,positions,plan,read,simulate,build,send,decode -
Manifest and schemas
--llmsandschema <method> -
Protocol-level output shaping
output.paths,output.view,output.limit -
Built-in summaries
summary,highlights,bestMatch,effects -
Structured error advice
retryable,likelyCauses,suggestedNextActions
From npm:
npm install -g agentrailRun without global install:
npx agentrail --llmsFrom local source:
cd /path/to/AgentRail
bun install
bun linkAfter linking, the CLI is available as agentrail.
The legacy alias acp still works for compatibility.
For many read-only flows, the built-in public RPC defaults are enough to get started.
If you want custom RPCs, explorer-backed ABI resolution, or transaction signing, configure .env from .env.example or set the same variables directly in your environment.
For the full environment variable reference, see docs/configuration.md.
LLM-friendly manifest:
agentrail --llmsMethod schema:
agentrail schema contract.readMinimal signature mode, no full ABI required:
agentrail call read --json '{"chain":"bnb","address":"0x9B00a09492a626678E5A3009982191586C444Df9","function":"balanceOf(address)","args":["0x5f0599dade40b691caaf156ec7dc6121833d58bb"],"returns":["uint256"],"decimals":18}'Look up a known registry entry:
agentrail call lookup --json '{"chain":"bnb","protocol":"aave","symbol":"WBNB"}'Read a token balance with formatting:
agentrail call tokenBalance --json '{"chain":"bnb","token":"0x9B00a09492a626678E5A3009982191586C444Df9","owner":"0x5f0599dade40b691caaf156ec7dc6121833d58bb"}'Simulate an arbitrary DeFi contract call:
agentrail call simulate --json '{"chain":"bnb","address":"0xYourContract","function":"deposit(uint256,address)","args":["1000000000000000000","0xYourWallet"],"stateMutability":"nonpayable","caller":"0xYourWallet","policy":{"allowWrites":true,"simulationRequired":true}}'The repo currently includes Aave as one concrete higher-level adapter example:
agentrail call positions --json '{"chain":"bnb","owner":"0x5f0599dade40b691caaf156ec7dc6121833d58bb"}'One built-in adapter example today is reading Aave supplied positions on BNB:
agentrail call positions --json '{"chain":"bnb","owner":"0x5f0599dade40b691caaf156ec7dc6121833d58bb"}' --filter-output result.summary,result.highlightsAgentRail can also run as a long-lived stdio JSON server for agent runtimes and orchestration systems.
agentrail serveMinimal discovery request:
{"id":"1","method":"rpc.discover","params":{}}For protocol-level filtering, compact views, and more detailed server examples, see docs/protocol-mode.md.
Write paths are designed to be more agent-safe than raw SDK usage:
contract.simulatebefore execution- policy checks
- signer isolation
- explicit
caller - receipt decoding
- structured error advice
-
Structured first JSON in, JSON out.
-
Readable by models Prefer
summary,highlights,effects, andbestMatchwhere possible. -
Flexible ABI resolution
abi->abiPath-> Sourcify -> explorer -> built-in standards -> minimal function signature mode -
Higher-level over repeated glue Common tasks should be one method, not six stitched reads.
-
Small outputs matter Agents should be able to request only what they need.
AgentRail is strongest today for:
- contract inspection and simulation
- generic contract reads and token balance queries
- transaction build/send/decode flows
- protocol address lookup
- Aave BNB supply position reads as a current built-in adapter example
Run tests:
bun testRun typecheck:
bun run typecheckLive verification script:
bun run verify:liveBuild npm distributable files:
npm run build- License: MIT
- Contributing guide: CONTRIBUTING.md
- Project roadmap: ROADMAP.md
- Security policy: SECURITY.md
Good next expansions:
- richer protocol registries
- more high-level methods for DeFi protocols
- better live receipt decoding examples
- stronger protocol-native projections and pagination
- more chain coverage