Skip to main content

Models and errors

These objects appear across many endpoints. Each endpoint page also shows its full response schema. Field-level details come from the node (software 1.6.5) and were checked against https://mainnet-rpc.ama.one/api.

Encodings​

  • Public keys and addresses: Base58, 48 bytes (BLS12-381).
  • Hashes (entries, transactions, state roots): Base58, 32 bytes.
  • Signatures: Base58, 96 bytes.
  • Amounts: flat is an integer in base units (1 AMA = 1,000,000,000 flat). float is the same amount as a floating-point number, for display only.
  • State keys are raw byte strings, such as account: + the 48 raw public key bytes + :balance:AMA. Path parameters take them Base58-encoded; request bodies take the raw bytes.
  • VecPak is the node's binary serializer. It is used for the POST /api/contract/view and POST /api/proof/contractstate bodies and for the get_prefix response. The SDK's encode, decode and decodeContractStatePage handle it.

Entry​

An entry is a block. /api/chain/tip, /hash, /height and /height_with_txs return it, and so does the event_entry WebSocket message.

FieldMeaning
hashEntry hash
headerheight, slot, prev_slot, prev_hash, signer, dr, vr, root_tx, root_chain (older headers also carry root_validator)
tx_countNumber of transactions
seen_time_msWhen this node first stored the entry (Unix ms)
in_main_chainWhether it is the main-chain entry at its height
consensusscore (0 to 1), finality_reached, mut_hash; absent until the node has an attestation
mask, mask_activeOnly on special-meeting entries
txsOnly on /api/chain/height_with_txs

header.root_chain is returned as raw bytes inside the JSON string, not Base58, and bytes that are not valid UTF-8 come back as U+FFFD, so the value cannot be decoded from these responses. /api/proof/block/{height} returns a Base58 root_chain, but that copy is informational: a verifier trusts the root in the signed header (see Proof).

Transaction​

{
"hash": "BjiG4LmykcyQChYm21j2AeUHaFSA4G7ZhSpgsF2yWR5D",
"signature": "21g6Xxw2zjKvzLTN8FozqX6RpbwBcwTWDRn7ZAbYudFAdenbEgGhfWYzL7zVQKeMAJQjUkmm3kCfRo2tMAdXHNu1Z67S5DYQMWvFWMSXMjMroKJjCQQ3C8Zuk3Kk2VuRXz2R",
"metadata": { "status": "finalized", "entry_hash": "3mMUXo5FSQhYLs44saSVsVSFCJsVM5Xr8NrbNbAscWjE", "entry_height": 90323887 },
"tx": {
"signer": "637zrNXKDKB3K8kfKgbUnZF7BTYzL2sH7iCU9PsgAmJRcfjVcZj2Z81FU7ZHfugzbC",
"nonce": 1794240278958000000,
"action": { "op": "call", "contract": "Coin", "function": "mint", "args": ["5xsRJanjUKwSu7XFXfdKf8Vtu2uFsmyUqmpUPD2Cso6xMJo32JgRu7oTDEphQSJ4A9", "175000000000", "PRIME"] }
},
"result": { "error": "ok" },
"receipt": { "success": true, "result": "ok", "logs": [], "exec_used": "320380" }
}
  • metadata.status is pending (in the mempool), committed (in an entry that is not rooted yet) or finalized (at or below the rooted height). Transactions from /api/chain/txs_in_entry and /api/chain/height_with_txs have no status.
  • A pending transaction from /api/chain/tx/{txid} has no receipt or result.
  • metadata.tx_event (sent or recv) appears only on /api/chain/tx_events_by_account. That endpoint pages with a Base58 cursor_b58 query parameter. SDK 1.8.0 types its answer as { cursor, txs: Transaction[] } and sends the cursor as cursor_b58.
  • tx.action.args: printable ASCII values come back as text, other binary values as Base58.
  • tx.action may also carry attachments (coins or NFTs sent with the call) and attached_gas. Older transactions carry attached_symbol and attached_amount.
  • result.error is a legacy copy of receipt.result.
  • Transactions in the event_txs WebSocket message are pushed before their receipts are indexed: no metadata, and a placeholder receipt. Fetch /api/chain/tx/{txid} for the real one.

Proofs​

The proof endpoints return JSON. A state proof (/api/proof/contractstate, /api/proof/validator_record) has this shape, all values Base58:

{
"root": "2bUMn3yrdRZ1yx34vneUqjV6DiDL6V3i6qdUcyjRvND7",
"siblings": ["6CfJwrdbkQafC1gBus6VNTvzMQX8PGp8t4uH2PYCnkan", "..."],
"terminus": { "path": "6q6UJRKGkUnS5A8zdrUTx8RwVMkLXDoCg41cbCcy2GNH", "identity_hash": "3hgaiQm1dkBApjeiDHGjhbQADeATYk6KxsW5mwwvwrrF", "value_hash": "HRwGChzxUxnc4DYcYuy8QGKvsAUHN33iAc5mrN2CtMCu" }
}

terminus is the string "empty" when the key does not exist (a proof of non-inclusion). The contract state reply wraps one proof per key with entry_height, entry_hash and root_contractstate. To trust the root, compare it with /api/chain/consensus/{entry_height}, which carries the validators' quorum aggregate signature over the same claim. The proof is built at the node's tip, so that height may not be rooted yet; the consensus endpoint answers not_found until it is. The Proof tag page explains how the three proof types fit together.

In SDK 1.8.0, sdk.proof.getContractStateProof(key) returns the contract state reply as ContractStateProof, sdk.proof.getValidatorRecord(height) the validator record as ValidatorRecordProof, and sdk.proof.getBlockProof(height, { atHeight }) the block proof as BlockProof. Each state proof is typed HbsmtProof. See Proof API.

Paged get_prefix responses​

POST /api/contract/get_prefix takes the raw prefix bytes as the body (at least 8 bytes) and answers with a VecPak map, not JSON:

{ rows: { key => value, ... }, cursor: <Base58 string> | nil }
  • rows is a VecPak map of key to value, or an empty list when nothing matches.
  • Keys come back with the queried prefix stripped. Querying account:<pk>:balance: returns keys like AMA.
  • A page holds at most 1,000 rows or 1 MiB.
  • cursor is the Base58 key of the page's last row, or nil on the last page. Send the same request again with ?cursor=<cursor> to get the next page.
  • A prefix shorter than 8 bytes is rejected with HTTP 400 and a JSON body:
printf 'acct' | curl -s -X POST --data-binary @- https://mainnet-rpc.ama.one/api/contract/get_prefix
{"error":"prefix_too_short","min":8}

With the SDK, sdk.contract.getPrefixEntries() follows the cursor and returns every [key, value] pair as bytes:

import { AmadeusSDK, fromBase58 } from '@amadeus-protocol/sdk'

const sdk = new AmadeusSDK({ baseUrl: 'https://mainnet-rpc.ama.one/api' })
const encoder = new TextEncoder()
const decoder = new TextDecoder()

const owner = fromBase58('6Hy6Jp1kWrhmJcqaHFgUqMC8uSwx9Tr5MGzKcfTjq6bSyLD1mEsYRmy4kjVU9xSWGK')
const prefix = new Uint8Array([...encoder.encode('account:'), ...owner, ...encoder.encode(':balance:')])

// Follows the cursor until the last page
const entries = await sdk.contract.getPrefixEntries(prefix)
for (const [key, value] of entries) {
console.log(decoder.decode(key), decoder.decode(value))
}
AMA 218110157204202

To fetch one page at a time, decode each body with decodeContractStatePage:

import { decodeContractStatePage, prefixPagePath } from '@amadeus-protocol/sdk'

const apiBase = 'https://mainnet-rpc.ama.one/api'
const prefix = new TextEncoder().encode('bic:epoch:solutions_count:')

const fetchPage = async (cursor: string | null) => {
const response = await fetch(apiBase + prefixPagePath(cursor), {
method: 'POST',
body: prefix
})
return decodeContractStatePage(await response.arrayBuffer())
}

const firstPage = await fetchPage(null)
console.log(firstPage.entries.length, firstPage.cursor)

The older sdk.contract.getPrefix() cannot read the binary body; use getPrefixEntries(). Contract state covers key layouts and value decoders.

Status codes​

Most replies are HTTP 200 with an error field: "ok" on success, an error code otherwise. The other statuses are:

StatusBodyWhen
400{"error":"prefix_too_short","min":8}get_prefix with a prefix under 8 bytes
401{"error":"unauthorized"}/health and /metrics* without the node's bearer token
404{"error":"not_found"}Unknown route. Also an empty result on /api/chain/hash, /height, /height_with_txs, /tx and /txs_in_entry (including an entry with no transactions)
429{"error":"rate_limited"}Testnet /api/upow/* above the per-IP limit
503{"error":"not_providing_contractstate_snapshot"} or {"error":"snapshot_not_ready"}/api/sync/contractstate

Some malformed requests get no JSON reply at all: the node closes the connection and the public RPC hosts answer with a 5xx gateway error. This happens with a non-numeric height in the path, tx_by_filter with limit above 1000, a pk query on GET /api/contract/view, and a submit_and_wait that does not see the transaction within about 6 seconds.

Error codes returned with HTTP 200​

CodeReturned by
not_found/api/chain/consensus and /api/chain/consensus/{height} (height not rooted or no quorum), /api/proof/validator_record, /api/bridge/order, /api/bridge/remote_seal, and an unknown path under /api/bridge/
invalid_epoch, sol_not_found/api/epoch/sol_in_epoch (only the current epoch can be queried)
state_root_mismatch/api/proof/contractstate
height_not_in_main_chain, target_not_rooted, commitment_not_rooted, at_height_not_in_main_chain, out_of_range, proof_too_costly, snapshot_unavailable, pruned_history/api/proof/block/{height}. These carry context fields such as height, rooted_height, at_height or pruned_below_height.
invalid_args/api/bridge/remote_seal with a malformed hash or caller
Transaction rejections, e.g. invalid_signature, nonce_too_high, invalid_tx_nonce, not_enough_tx_exec_balance, too_large, txpool_full/api/tx/submit*. The SDK's getTransactionErrorMessage() maps the codes it knows to messages and returns Transaction failed: <code> for the rest; see Troubleshooting.

Contract calls report failures inside the result instead: success: false with the error in result (for example account_has_no_bytecode or invalid_bic_action from /api/contract/view). Both view endpoints replace every byte outside printable ASCII (and the backtick) in result and logs with ?.