CLI anchoring tutorial
Anchor demo data on staging, with optional queries for existing protocol records
Submit a data anchor to staging, then optionally query submission status, contributions, DIDs, and tasks.
Requirements: macOS, Homebrew, and jq. The configuration below includes the public API key of the helloworld demo App on staging. No separate credential file or App provisioning is required. Use this demo App for test data only; its credentials and demo records are shared with other participants.
If your goal includes Record issuance, start with the staging trial prerequisites. The shared demo App covers the anchor step. Issuance also needs an enrolled App, a Producer signer, prepaid storage, approved source rights and an allocation.
1. Install
For Record issuance use v0.2.18 or later. Upgrade with brew update and brew upgrade humanbased-ai/tap/xny.
jq prepares the anchor JSON and checks receipts; the optional queries do not require it. If jq --version reports no command, install jq with your package manager, for example:
2. Configure authentication
Configure the shared staging credential, create the helloworld-demo profile, and verify authentication:
The expected App ID is 2480520856900000000. Cloud identifies the App from the API key. The key is saved in the operating system's keychain, and the service URL is saved in the profile. Both remain available after restarting the terminal.
3. Prepare data
DEMO_TEXT is the text to submit. Each run creates a separate directory containing the payload, metadata, and idempotency key.
The example uses the demo App's shared task and DID to anchor simulated data on Base Sepolia. Keep the input files unchanged after submission.
Cloud authorizes the App, not the DID or task: any App with app:write can anchor to any task and name any contributor DID. Creating a task or DID through one App does not stop other Apps from writing to it.
Deduplication depends on the idempotency key and the complete request, not just the payload. Running this step again generates a new submission ID, timestamp, and idempotency key. It creates a new submission that can produce another on-chain transaction. To retry the same submission, see Optional: verify idempotent replay.
4. Anchor the data
Submit the data and save the job ID:
A successful response means the request was accepted. Poll every five seconds, up to 120 times. Polling stops on finalization, a terminal failure, or a request error:
In v0.1.2, terminal failures return a nonzero exit code. Pending status queries can still exit zero, so check the receipt status to confirm completion.
The final check should print true: the status is finalized and the chain ID is 84532. If the job is still pending, run the polling block again. A successful receipt contains tx_hash and onchain_entity_id; view the transaction in the Base Sepolia explorer.
Keep the original payload and the finalized onchain_entity_id (CF ID). With an enrolled issuing App, continue to issue a Record and verify its initial ownership. Queries and replay verification below are optional.
Optional queries
These commands query existing demo records and can run independently after authentication. They do not query the new submission created in step 4.
Submission execution status
The expected status is finalized. anchor status takes a job_id; there is currently no separate command to look up a submission by its business submission_id.
Contribution and lineage
Read an existing on-chain contribution:
Read the lineage of the same contribution:
This SAMPLE has no parent contribution, so its graph contains only itself and no edges. truncated: true indicates that the result was truncated.
DID contributions and holdings
List contributions for the demo DID:
List holdings for the same DID:
The contribution list contains records from the shared demo DID. Holdings can be empty; anchoring does not automatically grant Dataset shares.
Task, Campaign, and Frontier
Read the demo task:
List contributions under the task:
Read its Campaign:
Read its Frontier:
Task queries use a bytes32 on-chain ID, while submission metadata uses the business task ID helloworld-demo-task. The on-chain ID is the Keccak-256 hash (Ethereum keccak256) of the business ID's UTF-8 bytes. List commands return one page of results.
Optional: verify idempotent replay
Within 24 hours of preparing the data, retry with the same files and idempotency key:
A result of true confirms that the response contains the same job ID. A replay may return the original queued response; use anchor status for the current status. Do not use this replay step to resubmit old data after 24 hours.
Keep the input files and receipts in the submission directory. To submit new data, run cd .. and start again at step 3.
Last updated