Alodium Docs

CLI anchoring tutorial

Anchor demo data on staging, with optional queries for existing protocol records

CLI command reference

Submit a data anchor to staging, then optionally query submission status, contributions, DIDs, and tasks.

Requirements: macOS, Node.js 22 or later, 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.

1. Install

npm install -g @alodium_ai/alodium
alodium version

Use alodium v0.1.2 or later. To upgrade an existing installation, run npm install -g @alodium_ai/alodium@latest.

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:

brew install jq

2. Configure authentication

Configure the shared staging credential, create the helloworld-demo profile, and verify authentication:

export XNY_API_KEY=pk_live_PKN2j2QjQDr3sFdlR1UCHySQWTgJkcZl
unset XNY_API_URL XNY_PROFILE
alodium profile add helloworld-demo --url https://cloud.staging.alodium.xyz
printf '%s\n' "$ALOD_API_KEY" | alodium auth login --profile helloworld-demo
alodium profile use helloworld-demo
unset XNY_API_KEY
alodium auth status --profile helloworld-demo --output json

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.

DEMO_TEXT='Hello, this is my first Alodium record!'
DEMO_RUN="$(uuidgen)"
mkdir "$DEMO_RUN"
cd "$DEMO_RUN"
printf '%s\n' "$DEMO_RUN" > idempotency-key.txt
date -u '+%Y-%m-%dT%H:%M:%SZ' > prepared-at.txt
jq -n --arg text "$DEMO_TEXT" '{message:$text,source:"helloworld-cli-demo"}' > payload.json
jq -n \
  --arg submission "$DEMO_RUN" \
  --arg task "helloworld-demo-task" \
  --arg did "181348315960027670548318242565301745050" \
  --arg published "$(cat prepared-at.txt)" \
  '{submission_id:$submission,task_id:$task,contributor_did_id:$did,
    publisher:("did:alodium:"+$did),published_at:$published,
    kind:"SAMPLE",verdict:0,grade:0,tags:{application:"helloworld-cli-demo"}}' > metadata.json
shasum -a 256 metadata.json payload.json > inputs.sha256
cat payload.json

The example uses the demo App's shared task and DID to anchor simulated data on Solana devnet. 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:

alodium anchor push --profile helloworld-demo \
  --metadata metadata.json --payload payload.json \
  --content-type application/json \
  --idempotency-key "$(cat idempotency-key.txt)" \
  --no-wait --output json > submission.json &&
jq -er '.operation.job_id' submission.json > job-id.txt
cat submission.json

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:

for attempt in {1..120}; do
  alodium anchor status "$(cat job-id.txt)" --profile helloworld-demo --output json > receipt.json || break
  DEMO_STATUS="$(jq -r '.status' receipt.json)"
  printf 'Status: %s\n' "$DEMO_STATUS"
  if [ "$DEMO_STATUS" = finalized ]; then break; fi
  sleep 5
done
cat receipt.json
jq -e '.status == "finalized" and .cluster == "devnet"' receipt.json

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 cluster is devnet. 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 Solana devnet explorer.

The main walkthrough is complete once the anchor is finalized on devnet. 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

alodium anchor status ad9d33a3-5fb3-45ba-b7b1-ea82618e25bb --profile helloworld-demo --output json

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:

alodium query contributions detail --profile helloworld-demo \
  --contribution-id 265ycbsPx5aMeyDF46Yauj8B42xi42GksoGfjYDv2aFZ --output json

Read the lineage of the same contribution:

alodium query contributions lineage --profile helloworld-demo \
  --contribution-id 265ycbsPx5aMeyDF46Yauj8B42xi42GksoGfjYDv2aFZ \
  --direction both --depth 2 --node-limit 50 --output json

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:

alodium query dids contributions --profile helloworld-demo \
  --did-id 181348315960027670548318242565301745050 --page-size 10 --output json

List holdings for the same DID:

alodium query dids holdings --profile helloworld-demo \
  --did-id 181348315960027670548318242565301745050 --page-size 10 --output json

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:

alodium query tasks detail --profile helloworld-demo \
  --task-id 3w3Upkthc32oJn2Z8MT5Du3P3q9MtUn5VbkPHWYCMnzM --output json

List contributions under the task:

alodium query tasks contributions --profile helloworld-demo \
  --task-id 3w3Upkthc32oJn2Z8MT5Du3P3q9MtUn5VbkPHWYCMnzM --page-size 10 --output json

Read its Campaign:

alodium query campaigns detail --profile helloworld-demo \
  --campaign-id 9qCovH43ay9Z5o1imC276B1wxLde5hH9yhFTmiBvMLCg --output json

Read its Frontier:

alodium query frontiers detail --profile helloworld-demo \
  --frontier-id CFZ9EZ8aAGNYFupSJZAmYwYKzn2qj8QibSfF1RVnGzNY --output json

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 (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:

shasum -a 256 -c inputs.sha256 &&
alodium anchor push --profile helloworld-demo --metadata metadata.json --payload payload.json \
  --content-type application/json \
  --idempotency-key "$(cat idempotency-key.txt)" \
  --no-wait --output json > replay.json &&
jq -e --arg job "$(cat job-id.txt)" '.operation.job_id == $job' replay.json

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