Skip to main content
Glama
README.md
# Onrecord

MCP gateway for AI agents on HyperEVM, Elysium, Ethereum, Base and Arbitrum.

One URL gives an AI read access to five chains. Every transaction the AI prepares is simulated on the latest block, explained in plain words, checked by a fixed set of rules and written to a public record. The user signs in their own wallet. Onrecord never holds keys and never signs.

- Site: https://onrecordapp.xyz
- MCP endpoint (streamable HTTP, no auth): `https://onrecordapp.xyz/mcp`
- HTTP API: `https://onrecordapp.xyz/api/v1` ([OpenAPI](https://onrecordapp.xyz/api/v1/openapi.json))
- For agents: [llms.txt](https://onrecordapp.xyz/llms.txt)
- X: https://x.com/onrecordapp

## How it works

```
agent ──► /mcp ──► simulate ──► explain ──► risk check ──► record ──► signing link ──► user's wallet
```

1. **Ask.** The agent calls a tool over MCP (or the same thing over REST).
2. **Simulate.** `eth_call` + `eth_estimateGas` on the latest block, plus a `debug_traceCall` call trace where the RPC serves it, to get the real asset changes (what you send, what you get). Native balance is lent to the sender with a state override so an empty wallet can still be simulated.
3. **Explain.** Calldata is decoded from known ABIs, Sourcify verified ABIs, then public selector databases. The sentence is built from the decoded call and the simulation, not by a language model.
4. **Check.** Rules run in layers and the worst level wins: `pass`, `warn` or `block`. If a mandatory layer (simulation, contract code, known-bad list) cannot finish, the verdict is `block`. The check fails closed.
5. **Record.** Each check is stored with a SHA-256 hash of its canonical body. Every hour the hashes are rolled into a digest that includes the previous digest, so history cannot be rewritten quietly. Anyone can recompute both in the browser at `/verify`.
6. **Sign.** `prepare_tx` returns a link `/sign/<id>.<expiry>.<hmac>` valid 30 minutes. The page re-simulates, shows the same explanation and sends through the user's own wallet (EIP-1193). Blocked transactions never get a link.

## Rules

| id | level | what it catches |
| --- | --- | --- |
| `check_incomplete` | block | a mandatory layer (simulation, code, known-bad list) could not finish |
| `known_bad_address` | block | target or recipient is on a public scam list |
| `approval_to_eoa` | block | token approval to a plain address |
| `token_to_itself` | block | tokens sent to the token contract |
| `transfer_blocked` | block | the token cannot be moved by a holder (balance-slot state override test) |
| `policy_missing`, `policy_expired`, `policy_target_not_allowed`, `policy_tx_cap`, `policy_daily_cap` | block | breaks the agent Safe policy |
| `would_revert` | warn | simulation reverts |
| `unlimited_approval`, `approval_for_all` | warn | approval for everything |
| `unverified_contract`, `verification_unknown` | warn | source not verified, or verification could not be read |
| `upgradeable_proxy` | warn | EIP-1967 proxy, logic can change |
| `owner_privileges` | warn | owner can mint, pause, blacklist or set fees |
| `fresh_contract`, `age_unknown` | warn | contract younger than 72 hours, or age unknown |
| `transfer_tax` | warn | the token takes a cut on transfer |
| `most_of_balance` | warn | sends most of the wallet |
| `burn_recipient`, `data_to_eoa` | warn | common mistakes |

## Agent wallets

`agent_wallet_plan` builds a Safe 1-of-2 (owner + agent) through the official Safe v1.4.1 proxy factory (`0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67`, same address on all five chains). The owner can always remove the agent.

`set_policy` lets the owner sign a plain message (no gas) with per-transaction and 24-hour caps, an optional contract allow-list and an expiry. The signer must be a current Safe owner. Every `prepare_tx` with `safe` set is checked against the policy and blocked if it breaks it. The caps live in the gateway, not on chain.

## Tools

`about`, `get_chains`, `get_balance`, `get_tokens`, `get_tx`, `get_safe`, `simulate_tx`, `explain_tx`, `risk_check`, `prepare_tx`, `agent_wallet_plan`, `set_policy`, `get_policy`, `get_record`.

Example:

```bash
curl -s https://onrecordapp.xyz/mcp -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"risk_check","arguments":{"chain":"base","to":"0x4200000000000000000000000000000000000006","value":"0.1","data":"0xd0e30db0"}}}'
```

## Limits

- Simulation is a snapshot of the latest block; state can change before the transaction lands.
- No call traces on Elysium yet, so asset changes there come from decoding only.
- A `pass` is not a guarantee.
- 60 requests per minute per IP.
- Not built: swaps, private sends, on-chain cap module, on-chain digest anchor.

## Stack

Cloudflare Pages with an advanced-mode worker (`src/`, bundled with esbuild), D1 for records, digests, signing links, policies and rate limits, public RPCs with fallback, static pages in `pages/` rendered by `tools/site.py`.

```bash
npm install
python3 tools/site.py      # render pages into site/
node tools/build.mjs       # bundle src/ into site/_worker.js
npx wrangler pages dev site
node test/run.mjs http://localhost:8788
```

Needs a D1 binding `DB` (schema in `schema.sql`) and a secret `SIGN_SECRET`.

## License

MIT