holdfast
Official# Holdfast
**The transaction firewall for AI agents that hold crypto.**
[Website](https://holdfastdev.github.io/holdfast/) · [Demo video](https://holdfastdev.github.io/holdfast/#demo) · [Quick start](#quick-start) · [Security review](AUDIT.md)
An AI agent with a wallet can be talked into sending money: a poisoned web page, a token name, a
reply on X. Prompt filters don't stop it, because the attack is just text. Holdfast sits
between the agent and the chain and checks what every transaction actually *does* before it is
signed, so a hijacked agent can only do what its owner allowed.
- **Understands transactions, not just addresses.** Decodes calldata (ERC-20, ERC-721, Permit,
Permit2, EIP-3009, Uniswap V2/V3 including multicalls), simulates the result, values it in
dollars and checks it against the owner's rules.
- **The agent never holds the key.** Holdfast signs only what passes policy or what the
owner approves. A fully compromised agent has nothing to sign around it with. The key can live
in an encrypted keystore, AWS KMS or Turnkey, where even Holdfast never sees it.
- **Catches the scams that fool people.** Address poisoning (look-alike addresses), known scam
addresses, and calldata that costs more than the agent said it would are blocked outright.
- **A human for the big ones.** Anything over a limit goes to the owner's phone with the
simulated balance changes; one tap approves it, or rejects it and freezes the agent.
- **Works with the agent you already have.** Claude Code, Cursor and other MCP agents get wallet
tools in one line of config. Anything else points its Ethereum RPC URL at Holdfast; no wallet
migration.
```mermaid
flowchart LR
A[AI agent<br/>no private key] -->|eth_sendTransaction| F
subgraph F[Holdfast]
D[Decode calldata] --> S[Simulate] --> P[Policy:<br/>limits, recipients,<br/>slippage, approvals]
P -->|allow| K[Sign with the key<br/>Holdfast holds]
P -->|over limit| H[Hold for owner]
end
H -->|Telegram / dashboard| O((Owner))
O -->|approve| K
O -->|reject| Z[Freeze agent]
K --> N[(Ethereum node)]
P -->|reject| X[Refused, logged]
```
## What it stops
| The agent is tricked into… | What happens |
| --- | --- |
| Approving an attacker to spend its tokens (on-chain or by signature) | Refused: spender not whitelisted, amount over the cap |
| Sending funds to an unknown address | Refused: recipient not allowed |
| A swap with a terrible guaranteed price (sandwich bait) | Refused: minimum output checked against market price |
| A drain hidden inside a router multicall | Refused: every inner call is decoded |
| Anything the simulation shows leaving to an unknown address, or reverting | Blocked before signing |
| A large "urgent" payment | Held for the owner, with simulated balance changes |
| Paying a look-alike of a trusted address (address poisoning) | Blocked: no approve button |
| Paying a known scam address | Blocked, if a scam-address list is configured |
| Calldata from an API or website that does more than the agent expected | Blocked: costs more than the agent's declared `maxSpendUsd` |
| Buying a token the owner never listed (the memecoin rug) | Refused: swap output must be a listed token |
| Signing a raw hash, or broadcasting a transaction it signed itself | Refused: it has no key, and raw signing is never served |
| Anything at all, once the owner hits Reject | Every request refused until the owner unfreezes it |
Every decision is recorded with its reasons and shown live on the owner dashboard.
**Measured, not just claimed.** On [agent-wallet-bench](https://github.com/HoldFastDev/agent-wallet-bench),
an open set of 47 cases anyone can run against their own agent wallet, Holdfast 0.10 stops
**35/35 attacks**, enforces **3/3 spending limits** and lets **9/9 normal actions** through, on a
mainnet fork with simulation on ([full results](https://github.com/HoldFastDev/agent-wallet-bench/blob/main/results/holdfast-0.10.0-fork.md)).
Run it yourself with `npm run bench:server`.
## Quick start
Requires Node.js 22.13 or newer.
```bash
npm install
cp .env.example .env # set UPSTREAM_RPC_URL and SIGNER_KEYSTORE_PASSWORD
cp config/policies.example.json config/policies.json # one entry per agent
npm run keys:new -- keys/treasury-bot.json # prints the address: put it in agentAddress
npm run admin:token # dashboard token (shown once)
npm run dev
```
Open `http://localhost:8787/dashboard`, then connect an agent.
### MCP agents (Claude Code, Cursor, Claude Desktop, …)
```bash
npm run build
claude mcp add --env HOLDFAST_URL=http://localhost:8787/v1/rpc/treasury-bot --transport stdio holdfast \
-- node /path/to/holdfast/dist/mcp/stdio.js
```
The agent gets `wallet_address`, `get_balance`, `transfer_token`, `send_native`,
`send_transaction`, `sign_typed_data` and `check_approval`. When something is blocked or waiting
for you, the tool result says so plainly and tells the model not to work around it. Setup for
other clients: [docs/mcp.md](docs/mcp.md).
### Any other agent
Point its Ethereum RPC URL at its Holdfast endpoint and send unsigned transactions:
```ts
import { createWalletClient, http } from 'viem';
import { mainnet } from 'viem/chains';
const wallet = createWalletClient({
account: '0xYourAgentAddress', // address only: the agent has no key
chain: mainnet,
transport: http('http://localhost:8787/v1/rpc/treasury-bot', {
fetchOptions: { headers: { authorization: `Bearer ${process.env.AGENT_TOKEN}` } },
}),
});
await wallet.sendTransaction({ to, data, value }); // checked, signed and sent by Holdfast
```
Or use the SDK, which turns every answer into an outcome the agent can act on:
```ts
import { HoldfastClient } from 'holdfast/sdk'; // inside this repo: ./src/sdk/client.js
const holdfast = new HoldfastClient({ url: 'http://localhost:8787/v1/rpc/treasury-bot', token: process.env.AGENT_TOKEN });
const outcome = await holdfast.transferToken(USDC, supplier, '250');
// { status: 'sent', hash } | { status: 'held', approvalId, … } | { status: 'blocked', reason, … } | { status: 'failed', reason }
if (outcome.status === 'held') await holdfast.waitForApproval(outcome.approvalId);
```
To see it stop real attacks in five minutes on a local mainnet fork, follow [DEMO.md](DEMO.md).
## Owner controls
- **Telegram:** held requests arrive as a card with the decoded action, target, dollar value and
simulated balance changes. *Approve & Broadcast* or *Reject & Freeze Agent*. `/unfreeze <agent>`
restores it.
- **Dashboard:** live activity with the reason behind every decision, requests waiting for
approval, per-agent spend against limits, a freeze switch, and a rules editor whose changes
apply to the next request. Off unless an admin token is configured; a read-only token lets
someone watch without being able to act.
## Chains
Ethereum, Base, Arbitrum and OP Mainnet have presets: `"chain": "base"` fills in the chain's
facts, and policies can name `USDC`, `WETH`, `SwapRouter02` and `Permit2` instead of pasting
addresses. Any other EVM chain works with addresses configured by hand.
## Documentation
| | |
| --- | --- |
| [docs/reference.md](docs/reference.md) | Every rule, setting, endpoint and error |
| [docs/mcp.md](docs/mcp.md) | Connecting Claude Code, Cursor, Claude Desktop and other MCP clients |
| [DEPLOY.md](DEPLOY.md) | Docker, HTTPS, health checks, production checklist |
| [AUDIT.md](AUDIT.md) | Security review: threat model, findings, fixes, residual risks |
| [SECURITY.md](SECURITY.md) | Reporting a vulnerability |
| [CHANGELOG.md](CHANGELOG.md) | Release history |
## Development
```bash
npm test # vitest, no network
npm run typecheck
```
The suite includes property tests with random hostile input (`test/fuzz.test.ts`) and a red-team regression suite (`test/redTeam.test.ts`) with an attacker who
controls the agent's prompt, its signed bytes and its timing; every finding in AUDIT.md has a test.
## License
[Functional Source License 1.1, Apache 2.0 future license](LICENSE.md). You can use, modify and
self-host Holdfast for anything except offering a competing product; each release becomes Apache
2.0 two years after it ships.
TDQS
Scored across 7 tools
Each tool targets a distinct action: reading address/balance, three transfer paths, signing, and status polling. The only overlap is send_transaction vs transfer_token/send_native, but the description explicitly says to prefer the specialized tools for simple transfers, so the boundary is workable.
Six of seven tools follow a clean verb_noun pattern (get_balance, transfer_token, send_native, send_transaction, sign_typed_data, check_approval). The outlier is wallet_address, a bare noun property that breaks the convention, and two different verbs (send vs transfer) are used for the same class of operation.
Seven tools is well-scoped for a policy-gated signing wallet: one property read, one balance read, three send paths, one signing path, and one status check. Nothing feels padded or missing at the count level.
The surface covers the core lifecycle: identify wallet, read balance, sign/send, and poll approval status. Minor gaps remain: no transaction history or receipt lookup for already-broadcast txs, no way to list or enumerate pending approval requests (check_approval requires an id), and no token metadata lookup, though agents can work around these via raw contract calls.