anchor_document
Anchor a document hash on Midnight in one call: submit an attestation with a sponsor paying the fee and wait for on-chain confirmation. Retry with an idempotency key to resume pending jobs.
Instructions
Anchor a document hash on Midnight in one call: builds the attest transaction here with the caller seed, a sponsor pays the fee, and the tool waits until it landed (about 1 to 2 minutes; the first call also downloads the prover keys). The record belongs to this seed (attesterId). Only the hash and the hash of the metadata go on-chain; keep the document yourself. With contentRoot and schemaId from prepare_document_proof it also anchors the content root, which the field claims of submit_vault_call need. Returns { status, attesterId, payloadHash, contractAddress, metadataJson, txHash, transactionHash, timings, check }; check is the verify_attestation call that shows the record on-chain. If the call was cut off or came back pending, run it again with the same arguments: it picks up the job it started and submits nothing new (the answer says deduplicated). With an idempotencyKey that also holds after a restart of this server. A second, separate call with the same arguments needs a new idempotencyKey.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sha256": "<sha256>"
},
"name": "anchor_document"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sha256 | Yes | sha256 of the document (64 hex); it becomes the payloadHash | |
| metadata | No | Public metadata; its sha256 is anchored with the hash. Default none | |
| schemaId | No | Schema id from prepare_document_proof (64 hex); needs contentRoot | |
| contentRoot | No | Content root from prepare_document_proof (64 hex); needs schemaId | |
| idempotencyKey | No | Dedupes retries of the same anchor | |
| contractAddress | No | AttestationVault address (64 hex); default NIGHTGATE_SANDBOX_VAULT, else the shared sandbox vault of the network (preprod, preview) | |
| compiledArtifactRef | No | Vault lineage, default 'attestation-vault-32' (the sandbox vaults); 'attestation-vault' for a 16-slot vault |