On-Chain API
Part of CLPI Phase 4: On-Chain Verification. The On-Chain API anchors reputation data to Base L2 for immutable, third-party-verifiable trust records.
https://api.mnemom.ai/v1/on-chain
Authentication
| Endpoint | Auth Required | Notes |
|---|---|---|
POST /v1/on-chain/anchor-root | API key | Anchors a Merkle root on-chain |
POST /v1/on-chain/publish-scores | API key | Publishes scores on-chain |
GET /v1/on-chain/verify-proof/{agent_id} | API key | Verifies an agent’s on-chain score |
GET /v1/on-chain/status/{agent_id} | API key | Checks on-chain status for an agent |
GET /v1/on-chain/history | API key | Retrieves anchoring and publishing history |
Authorization header:
POST /v1/api-keys.
Rate Limits
| Endpoint | Rate Limit | Window |
|---|---|---|
POST /on-chain/anchor-root | 10 requests | per minute |
POST /on-chain/publish-scores | 10 requests | per minute |
GET /on-chain/verify-proof/{agent_id} | 30 requests | per minute |
GET /on-chain/status/{agent_id} | 30 requests | per minute |
GET /on-chain/history | 30 requests | per minute |
429 with a Retry-After header.
Endpoints
POST /v1/on-chain/anchor-root
Anchor a Merkle root from the integrity checkpoint tree to theMnemoMerkleAnchor contract on Base L2. Creates an immutable, tamper-evident reference point for off-chain checkpoint data.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
merkle_root | string | Yes | Merkle root hash to anchor (hex-encoded, 32 bytes) |
leaf_count | number | Yes | Number of leaves (checkpoints) in the tree |
tree_depth | number | Yes | Depth of the Merkle tree |
200 OK
| Field | Type | Description |
|---|---|---|
anchor_id | string | Unique identifier for this anchor operation |
merkle_root | string | The anchored Merkle root (echoed back) |
tx_hash | string | Base L2 transaction hash |
block_number | number | Block number containing the anchor transaction |
gas_used | number | Gas consumed by the transaction |
chain | string | Chain identifier (always "base") |
anchored_at | string | ISO 8601 timestamp of when the root was anchored |
| Status | Meaning |
|---|---|
400 | Invalid Merkle root format, missing required fields, or invalid tree parameters |
401 | API key required or invalid |
409 | Merkle root has already been anchored |
429 | Rate limit exceeded |
POST /v1/on-chain/publish-scores
Publish one or more agent reputation scores to theMnemoReputationRegistry contract on Base L2. Scores are published in a single batch transaction for gas efficiency.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
publications | array | Yes | Array of score publication objects (max 200) |
publications[].agent_id | string | Yes | Agent identifier |
publications[].score | number | Yes | Composite reputation score (0-1000) |
publications[].grade | string | Yes | Letter grade: AAA, AA, A, BBB, BB, B, or CCC |
200 OK
| Field | Type | Description |
|---|---|---|
publication_id | string | Unique identifier for this publication batch |
tx_hash | string | Base L2 transaction hash |
block_number | number | Block number containing the publish transaction |
gas_used | number | Gas consumed by the transaction |
agent_count | number | Number of agents published in this batch |
published_at | string | ISO 8601 timestamp of when scores were published |
| Status | Meaning |
|---|---|
400 | Missing publications, empty array, exceeds 200 agents, invalid score range, or invalid grade |
401 | API key required or invalid |
404 | One or more agent IDs not found |
422 | One or more agents do not have a computed reputation score (below 50-checkpoint minimum) |
429 | Rate limit exceeded |
GET /v1/on-chain/verify-proof/
Verify an agent’s on-chain reputation score and retrieve the cryptographic proof linking the on-chain record to the underlying integrity data. Parameters:| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes | Agent identifier |
200 OK
| Field | Type | Description |
|---|---|---|
agent_id | string | Agent identifier |
on_chain_score | number | Score as recorded on-chain (0-1000) |
grade | string | Letter grade as recorded on-chain |
metadata_hash | string | keccak256 hash of the off-chain metadata at time of publication |
published_at | string | ISO 8601 timestamp of when the score was published on-chain |
block_number | number | Block number containing the publication transaction |
tx_hash | string | Transaction hash of the publication |
verified | boolean | Whether the on-chain score matches the current off-chain score and the proof is valid |
| Status | Meaning |
|---|---|
401 | API key required or invalid |
404 | Agent not found or no on-chain score exists for this agent |
429 | Rate limit exceeded |
GET /v1/on-chain/status/
Check whether an agent has an on-chain score and retrieve the current on-chain state, including the latest score and anchor information. Parameters:| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes | Agent identifier |
200 OK
| Field | Type | Description |
|---|---|---|
agent_id | string | Agent identifier |
has_on_chain_score | boolean | Whether this agent has at least one published on-chain score |
latest_score | object | null | Latest on-chain score record, or null if no score exists |
latest_score.score | number | Most recent on-chain score |
latest_score.grade | string | Most recent on-chain grade |
latest_score.block_number | number | Block number of the latest publication |
latest_score.published_at | string | Timestamp of the latest publication |
latest_anchor | object | null | Latest Merkle root anchor relevant to this agent, or null |
latest_anchor.merkle_root | string | The anchored Merkle root |
latest_anchor.block_number | number | Block number of the anchor transaction |
latest_anchor.anchored_at | string | Timestamp of the anchor |
last_updated | string | Most recent on-chain activity timestamp for this agent |
| Status | Meaning |
|---|---|
401 | API key required or invalid |
404 | Agent not found |
429 | Rate limit exceeded |
GET /v1/on-chain/history
Retrieve the paginated history of on-chain anchoring and score publishing events for your account. Query parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number (default: 1) |
per_page | number | No | Results per page (default: 20, max: 100) |
200 OK
| Field | Type | Description |
|---|---|---|
anchors | array | List of Merkle root anchor events |
anchors[].anchor_id | string | Unique anchor identifier |
anchors[].merkle_root | string | The anchored Merkle root hash |
anchors[].leaf_count | number | Number of leaves in the tree |
anchors[].tree_depth | number | Depth of the Merkle tree |
anchors[].tx_hash | string | Transaction hash |
anchors[].block_number | number | Block number |
anchors[].anchored_at | string | ISO 8601 timestamp |
publications | array | List of score publication events |
publications[].publication_id | string | Unique publication identifier |
publications[].agent_count | number | Number of agents in the batch |
publications[].tx_hash | string | Transaction hash |
publications[].block_number | number | Block number |
publications[].published_at | string | ISO 8601 timestamp |
page | number | Current page number |
per_page | number | Results per page |
total_anchors | number | Total anchor events across all pages |
total_publications | number | Total publication events across all pages |
| Status | Meaning |
|---|---|
401 | API key required or invalid |
429 | Rate limit exceeded |
Error Codes
| Status | Code | Description |
|---|---|---|
400 | invalid_request | Missing or invalid parameters (e.g., malformed Merkle root, score out of range, invalid grade) |
401 | unauthorized | API key required but not provided or invalid |
404 | not_found | Agent not found or no on-chain data exists for the specified agent |
409 | already_anchored | The specified Merkle root has already been anchored on-chain |
422 | ineligible_agent | Agent does not have a computed reputation score (below 50-checkpoint minimum) |
429 | rate_limited | Too many requests; check Retry-After header |
500 | internal_error | Server error; retry with exponential backoff |
502 | chain_unavailable | Base L2 network is temporarily unavailable; retry after a short delay |
SDK Usage
TypeScript
Python
See Also
- On-Chain Verification Concepts — How on-chain anchoring and publishing work
- On-Chain Verification Guide — Step-by-step usage guide
- Mnemom Trust Rating — Understanding reputation scores
- Trust Rating API — API reference for off-chain reputation endpoints
- Integrity Checkpoints — The data source for Merkle trees