Skip to main content

Overview

AgentChain SDK v2 introduces the EVM guard flow — a pre-transaction policy check that returns a signed receipt before any value moves on-chain.

Install

Create a client

Create a policy

Before guarding any transaction, create a policy for your chain and contract:

Guard and execute

Guard only (no execution)

If you want the policy decision without executing, use guardTransaction:
decisionExpiresAt — The gateway sets this to issuedAt + 300s. If execution takes more than 5 minutes, call guardTransaction again for a fresh receipt. guardAndExecute throws AgentChainExpiredDecision automatically if the window has closed.

Verify a receipt locally

No network call required:

Verify on-chain (SignerAnchor)

For trustless verification — confirm the signer is authorized at the contract level:

Next steps


Security notes for pilots

Simulation fail-closed behavior

When simulate: true is set in the guard request and the RPC circuit breaker is OPEN (too many consecutive simulation failures), the guard returns 503 SIMULATION_DEGRADED. All subsequent guard requests with simulate: true will fail until the circuit recovers. Pilots should decide their fallback strategy upfront: The circuit auto-recovers after 60 seconds of no failures (HALF_OPEN → CLOSED).

4-byte selector collision limitation

allowedSelectors matches on the first 4 bytes of calldata. Two different Solidity functions can share the same 4-byte selector (keccak256 collision). This is extremely unlikely in practice but is a documented limitation. Mitigation: Combine allowedTargets + allowedSelectors — both must match. The probability of a meaningful collision on a specific target contract is negligible for standard EVM deployments.