Live today
Quickstart
Five minutes: send a transaction that should not be signed, watch Metera refuse it for free, and verify the signed receipt yourself.
Live1. Get a key
Create a live API key in the dashboard, at metera.xyz/dashboard/api-keys. It starts with mk_live_ and is shown once. The preflight checks live chain state, so it needs a live key; a refuse costs nothing. Below, replace YOUR_API_KEY with it.
2. Send a transaction that should be refused
Save this as refuse.json. The transaction is a one-lamport transfer from an empty wallet, presented as a swap on a pool it never touches. An agent should never sign it.
{
"transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAECfeHl7pNDQ0q/hQ4irh6V6PEf3/0kDL9Yf9kXCRmTxdIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG65PbI2bBrOPRvROzqZaEpiWchRz/eKkDFK0bYj+sZIAQECAAAMAgAAAAEAAAAAAAAA",
"intent": {
"pool": "58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2",
"taker": "9UPkNHrz5QvjpBpQpmMH2pxGtuTGpy8Nm91qybVroN3j",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"direction": "exact_in"
},
"policy": { "maxPriceImpactBps": 50 }
}curl -s https://api.metera.xyz/v1/preflight \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
--data @refuse.json > verdict.json3. Read the verdict
HTTP 200, like every verdict. Abridged:
{
"decision": "refuse",
"decision_id": "…",
"consensus_reasons": [
{ "layer": "layer1", "reason": "fee payer … does not exist on chain" },
{ "layer": "layer1", "reason": "blockhash … is no longer in the ~150-slot queue (BlockhashNotFound) …" },
{ "layer": "layer2_swap", "reason": "intent.pool … did not resolve: … is owned by 675kPX9M…, not the Raydium CPMM program" }
],
"receipt": { "receipt": { "verdict": "refuse", "message_hash": "sha256:…", "key_id": "ed25519:1886527ed07c735b", "…": "…" }, "alg": "Ed25519", "signature": "…" },
"debitedCreditsTotal": 0
}- consensus_reasons: facts about the chain. Any one refuses; no policy overrides it.
- decision_id: the row this verdict was written to in the append-only decision log, before it was sent to you.
- debitedCreditsTotal: 0: a refuse is free.
4. Verify the receipt yourself
The receipt is Metera’s Ed25519 signature over the verdict and the exact message it is about. Check it against the published key, with the transaction you sent:
Save this next to the two files as verify.mjs. It needs Node 20 or later and nothing else:
// verify.mjs — Node 20+, no dependencies
import { readFileSync } from 'node:fs'
import { createHash, createPublicKey, verify } from 'node:crypto'
const { transaction } = JSON.parse(readFileSync('refuse.json', 'utf8'))
const { receipt } = JSON.parse(readFileSync('verdict.json', 'utf8'))
const { keys } = await (await fetch('https://api.metera.xyz/v1/receipts/keys')).json()
// Canonical JSON: keys sorted at every level, no whitespace.
const canon = (v) => Array.isArray(v) ? `[${v.map(canon).join(',')}]`
: v && typeof v === 'object' ? `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${canon(v[k])}`).join(',')}}`
: JSON.stringify(v)
// 1. The Ed25519 signature, with the published key the receipt names.
const key = keys.find((k) => k.key_id === receipt.receipt.key_id)
const spki = Buffer.concat([Buffer.from('302a300506032b6570032100', 'hex'), Buffer.from(key.public_key, 'base64')])
const signed = Buffer.from('metera-receipt/v1\n' + canon(receipt.receipt), 'utf8')
const signature = verify(null, signed, createPublicKey({ key: spki, format: 'der', type: 'spki' }), Buffer.from(receipt.signature, 'base64'))
// 2. The message hash, recomputed from the bytes you sent: skip the signature section.
const tx = Buffer.from(transaction, 'base64')
let n = 0, i = 0, shift = 0, b
do { b = tx[i++]; n |= (b & 0x7f) << shift; shift += 7 } while (b & 0x80)
const messageHash = 'sha256:' + createHash('sha256').update(tx.subarray(i + 64 * n)).digest('hex')
console.log({ signature: signature ? 'valid' : 'invalid', message_hash: messageHash === receipt.receipt.message_hash ? 'match' : 'mismatch' })node verify.mjs
# { signature: 'valid', message_hash: 'match' }message_hash: match means the hash was recomputed from the bytes you hold, not taken from Metera. Change one character of the receipt and signature turns invalid. To avoid asking Metera for the key at all, pin it: ed25519:1886527ed07c735b, see Receipts.
5. The same thing from an agent
Over MCP, the tool is preflight_transaction, with the same body:
claude mcp add --transport http metera https://api.metera.xyz/mcp \
--header "Authorization: Bearer YOUR_API_KEY"From TypeScript, with @metera/sdk 0.7.0, where verifyReceipt is one call. 0.7.0 is on its way to npm; the 0.6.0 there today is an older, unrelated package, so do not install it for this.
import { Metera } from '@metera/sdk'
const metera = new Metera('YOUR_API_KEY')
const verdict = await metera.preflight({ transaction, intent, policy })
if (verdict.decision === 'refuse') return // do not sign
const check = await metera.verifyReceipt(verdict.receipt, { transactionBase64: transaction })Next
- API reference: every route, request, response and error.
- Preflight and What we verify: what the checks cover and where the scope ends.
- Receipts: what a receipt proves, and what it does not.
