Book a free call

Guardrails for Onchain AI Agents: A Practical Guide

Guardrails for onchain AI agents cap spending, check transactions before signing and stop an agent that behaves oddly. Design them before an agent holds a wallet.

Hertiv engineering teamReviewed by a senior engineer
7 min read
Guardrails for Onchain AI Agents: A Practical Guide
On this page

Short answer

Guardrails for onchain AI agents are the limits and checks placed between an agent and the blockchain it acts on: spending caps, token allowlists, transaction simulation, approval thresholds and kill switches. They exist because an onchain agent can move real money and sign real contracts, so a mistake or a bad instruction can cost funds in seconds rather than hours.

What are guardrails for onchain AI agents?

Guardrails for onchain AI agents are the rules and controls that limit what an agent can do with a wallet and a blockchain. They sit between the agent's decisions and the chain: every proposed transaction is checked against the rules, and anything outside them is blocked, queued for a human, or stopped entirely.

An onchain agent is different from a chatbot because it takes actions that cannot be undone. A chatbot that gives a wrong answer can be corrected; an agent that sends funds to the wrong address, approves a bad contract or drains a treasury cannot take it back. The guardrails are what make that risk manageable.

The controls fall into a few groups: limits on how much can move, rules on where it can go, checks on what the transaction actually does, and a way to stop the agent. No single control is enough; they work as a set, so that one failure does not hand the agent the keys.

Guardrails are not the same as the agent's instructions. Instructions tell the agent what to try to do; guardrails set what it is allowed to do at all. The two should be written and reviewed separately, by different people where possible.

Why do onchain agents need different guardrails?

Onchain agents need different guardrails because their actions are irreversible, public and fast. A transaction that is signed and confirmed cannot be recalled, anyone can read it, and it settles in seconds, so there is no time for a human to notice and intervene after the fact.

Four properties drive the difference:

Property What it means Guardrail it needs
Irreversible Confirmed transfers cannot be recalled Pre-sign checks and caps
Fast Transactions settle in seconds Automated checks, not human review
Public Anyone can read the transaction Allowlisted addresses only
Programmable Contracts can call other contracts Simulation before signing

The programmable part is the one teams miss most. An agent that approves a token spend for one contract may find that contract calling another, and the second call moving funds somewhere unexpected. A guardrail that only checks the first call is not enough.

Ordinary AI guardrails still apply: the agent should not be tricked by text in a document or a message into acting against its owner. Onchain, that prompt injection risk is worse, because the payload is a transaction. For the general patterns, what are AI guardrails covers how guardrails work in any agent.

What should guardrails check before a transaction?

Guardrails should check five things before a transaction is signed: how much is moving, where it is going, what the transaction actually does, whether the agent is behaving normally, and whether a human needs to approve it.

  • Spending caps. A maximum amount per transaction, per day and per token. A cap turns a bad decision into a small loss instead of a large one.
  • Address allowlist. A list of addresses the agent may pay, and a rule that anything else needs human approval. New addresses should never be added by the agent itself.
  • Token allowlist. Only the tokens the agent is meant to hold and move. Anything else is blocked, so a stray token cannot be spent by mistake.
  • Simulation. Run the transaction against the current chain state before signing, and check the result: the amounts, the recipient and every contract the call touches.
  • Behaviour checks. Compare the proposed action with the agent's normal pattern. A sudden change in size, frequency or destination is a reason to stop and ask.

Approval thresholds tie these together: small, routine transactions within the caps can go through automatically, while anything above the threshold, to a new address, or outside the normal pattern waits for a human. The threshold should be low enough that a mistake is cheap.

Every check needs a log entry: what was proposed, what the checks found, and whether it was allowed, blocked or queued. Without the log, you cannot tell after the fact whether the guardrails worked.

How do you build guardrails for an onchain agent?

You build guardrails for an onchain agent by putting the controls in the wallet and the signing path, not only in the agent's instructions, so the agent cannot talk its way past them.

  1. Separate the wallet. Give the agent its own wallet with only the funds it needs for the current task, funded from a main wallet it cannot touch.
  2. Set the caps. Write the per-transaction and daily limits into the wallet policy or a smart contract, not into a prompt.
  3. Build the allowlists. List the addresses and tokens the agent may use, and require a human to change the lists.
  4. Add simulation. Run every proposed transaction against the chain state first, and block anything whose simulated result differs from what the agent described.
  5. Add approval for big moves. Route anything above the threshold, to a new address or outside the normal pattern to a human with the full details.
  6. Add a kill switch. A way to freeze the agent's wallet and stop all signing, tested before launch, so a runaway agent can be stopped in seconds.

Test the guardrails by trying to break them: ask the agent to send more than the cap, to a new address, and to approve a contract that calls another contract. Each attempt should be blocked or queued, and each one should appear in the log.

For the step-by-step implementation pattern, how to implement AI guardrails covers the design and testing sequence that applies here too.

Example: a treasury agent with a daily cap

Example (hypothetical): a small company uses an agent to pay supplier invoices in stablecoins. The agent reads invoices from an inbox, checks them against purchase orders, and pays the ones that match. The main wallet holds the company's funds; the agent's wallet is topped up each morning.

The guardrails are simple: the agent wallet holds at most $5,000, no single payment may exceed $1,000, payments may only go to suppliers on the allowlist, and anything above $500 needs a human to approve it in the morning queue. Every proposed payment is simulated first, and the simulation must show the exact supplier address and amount.

One morning the agent proposes a $900 payment to a supplier, which is within the cap but above the $500 approval threshold, so it waits for a human.

Another invoice names a new supplier not on the allowlist, so that payment is blocked and the team is asked to check the supplier first. The arithmetic stays simple: with a $5,000 wallet and a $1,000 per-payment cap, the most the agent can move without a human is five payments, and each one is logged.

The company reviews the log each week: how many payments went through, how many were queued, and how many were blocked. After a month with no blocked payment that turned out to be legitimate, the team raises the approval threshold to $750. The guardrails are tuned from evidence, not from a guess.

How do you monitor and revoke an onchain agent?

You monitor an onchain agent by watching its wallet and its log in real time, and you revoke it by freezing the wallet and removing its keys, so that monitoring is a control, not a report you read next week.

What to watch:

  • Wallet balance and flows. How much left the wallet, to whom, and how fast. A spike in volume or frequency is the first sign of trouble.
  • Blocked and queued actions. How often the guardrails fired, and whether the blocked actions were attacks, mistakes or legitimate work held up by a bad rule.
  • New addresses and tokens. Any payment to an address that was not on the allowlist yesterday needs a human to look at it.
  • Failed simulations. A transaction whose simulation differs from what the agent described is a reason to stop the agent, not to retry it.

Revocation must work even if the agent is misbehaving: the kill switch freezes signing at the wallet, and the keys can be rotated without the agent's cooperation. Test the revocation path before launch, the same way you test the guardrails, because a kill switch you have never used is a guess.

For the security side of agent access, how to secure AI agents covers permissions, logging and credential hygiene that apply to onchain agents as well.

What are the common mistakes?

The most common mistakes are putting the guardrails in the prompt, funding the agent wallet with too much, and never testing the kill switch.

  • Guardrails in the prompt. Instructions can be overridden by text the agent reads. Limits must live in the wallet and the signing path.
  • Too much in the agent wallet. An agent wallet should hold only what the current task needs, topped up often, not the whole treasury.
  • No simulation. Checking the first call is not enough when contracts call other contracts. Simulate the whole transaction.
  • Approval thresholds too high. A threshold above the cost of a mistake means mistakes go through unchecked.
  • Never testing revocation. A kill switch that has never been used may not work when it is needed.
  • No log review. Guardrails that fire and nobody reads are a control in name only.

Key takeaways

  • An onchain agent can move real money in seconds, so guardrails must act before signing, not after
  • Limits belong in the wallet and the signing path, not in the agent's instructions
  • Caps, allowlists, simulation and approval thresholds work as a set, not on their own
  • Simulate the whole transaction: contracts can call other contracts
  • Test the kill switch before launch, and review the guardrail log every week

Frequently asked questions

What is an onchain AI agent?

An onchain AI agent is software that reads instructions, decides what to do, and then signs transactions on a blockchain: paying invoices, swapping tokens, voting in a DAO or managing a treasury. Because its actions move real funds, it needs guardrails that act before signing.

How is an onchain agent different from a normal AI agent?

The difference is that its actions are irreversible, public and fast. A normal agent that gives a wrong answer can be corrected; an onchain agent that sends funds to the wrong address cannot take it back. That is why the controls must sit in the wallet and the signing path.

What is the most important guardrail for an onchain agent?

Spending caps are the first control, because they turn a bad decision into a small loss. A per-transaction cap and a daily cap, written into the wallet policy, should come before anything else. Allowlists, simulation and approval thresholds add the next layers.

Should a human approve every onchain transaction?

No. Small, routine transactions within the caps can go through automatically, or the agent would be useless. Anything above the threshold, to a new address, or outside the agent's normal pattern should wait for a human, with the full details attached.

Can guardrails stop prompt injection attacks on an agent?

They can limit the damage. Guardrails in the wallet and signing path cannot be overridden by text the agent reads, so even if the agent is tricked into proposing a bad transaction, the caps, allowlists and simulation can block it. The agent itself still needs the usual defences against injected instructions.

How do you test guardrails before launch?

Try to break them on purpose: ask the agent to send more than the cap, pay a new address, and approve a contract that calls another contract. Each attempt should be blocked or queued, and each one should appear in the log. Also test the kill switch, so you know revocation works.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building an agent that will hold a wallet and sign transactions? Talk to Hertiv.

A senior engineer replies within one business day. Or see our AI Governance service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call