First Commit and Read

This guide walks you through running the Asset Core daemons locally, sending a simple commit, and reading back the resulting state.

Prerequisites

  • Rust toolchain (stable, via rustup)
  • HTTP client (curl or similar)
  • Terminal with two windows or tabs

Step 1 - Build the daemons

From the Asset Core repository root:

cargo build --release -p assetcored-write -p assetcored-read

This produces binaries in target/release/.

Step 2 - Start the write daemon

In the first terminal:

./target/release/assetcored-write --config daemon-write/config/default.toml

The write daemon starts on http://127.0.0.1:8080 by default.

Verify it’s running:

curl http://127.0.0.1:8080/v1/health

Expected response:

{
  "status": "healthy",
  "commit_log": { ... }
}

Step 3 - Start the read daemon

In the second terminal:

./target/release/assetcored-read \
  --listen 127.0.0.1:8081 \
  --commit_log commit_log.log \
  --checkpoint read.checkpoint.json

The read daemon tails the same commit log the write daemon uses.

Verify it’s running:

curl http://127.0.0.1:8081/v1/health

Step 4 - Send your first commit

Create a container and add fungible balance in a single transaction:

curl -X POST http://127.0.0.1:8080/v1/commit \
  -H "Content-Type: application/json" \
  -d '{
    "operations": [
      {
        "op": "CreateContainer",
        "args": {
          "container_id": 1001,
          "kind": "Standard",
          "owner": null
        }
      },
      {
        "op": "AddFungible",
        "args": {
          "container_id": 1001,
          "class_id": 100,
          "key": 1,
          "quantity": 500
        }
      }
    ],
    "idempotency_key": "first-commit"
  }'

Expected response:

{
  "global_seq": 1,
  "batch_seq": 1,
  "minted_instances": [],
  "metadata": {
    "idempotency_key": "first-commit"
  }
}

The global_seq confirms your commit was assigned sequence number 1.

Step 5 - Read back the state

Query the container balances:

curl http://127.0.0.1:8081/v1/read/container/1001/balances

Expected response:

{
  "container_id": 1001,
  "balances": [
    {
      "class_id": 100,
      "key": 1,
      "quantity": 500
    }
  ],
  "freshness": {
    "checkpoint_seq": 1,
    "commit_log_seq": 1
  }
}

The freshness metadata shows that the read daemon has processed all commits through sequence 1.

Troubleshooting

”Connection refused” on commit

The write daemon isn’t running or is on a different port. Check the terminal for errors and verify the --config path is correct.

Empty balances on read

The read daemon hasn’t caught up to the write daemon. Check that both daemons use the same commit log path. The freshness metadata shows the current checkpoint.

”ContainerNotFound” error

The container ID in your read query doesn’t match what you created. Container IDs are integers, not strings.

”InvalidQuantity” error

Quantity must be greater than zero. Check your AddFungible operation.

Next steps