Substates
Substates are the fundamental storage units on the Ootle network — components, vaults, resources, and more. The Provider interface exposes methods to read them.
Get a single substate
Section titled “Get a single substate”const substate = await provider.getSubstate("component_0x…");console.log(substate);Returns an IndexerGetSubstateResponse with the substate version and its state. The indexer serves the value CBOR-encoded (base64); upSubstateValue decodes it:
import { upSubstateValue } from "@tari-project/ootle";
const value = upSubstateValue(substate); // SubstateValue, or null if the version is downgetSubstate throws SubstateNotFoundError when the substate does not exist, or when the version you asked for has been spent. The error carries substateId and version, and the provider’s own error is its cause. Any other failure, such as a transport error or an indexer that is still syncing, is thrown as the provider’s own error. A custom Provider must follow the same contract.
import { SubstateNotFoundError } from "@tari-project/ootle";
try { await provider.getSubstate("component_0x…");} catch (err) { if (err instanceof SubstateNotFoundError) { // the substate does not exist (or that version is spent) } else { throw err; }}Fetch multiple substates
Section titled “Fetch multiple substates”import { decodeSubstateValue } from "@tari-project/ootle";
const { substates } = await provider.fetchSubstates(["component_0x…", "vault_0x…"]);for (const [id, substate] of Object.entries(substates)) { if (substate) console.log(id, substate.version, decodeSubstateValue(substate.value));}The SDK exports a decoder for each CBOR value the indexer serves: decodeSubstateValue, decodeExecuteResult (a finalized transaction’s execution_result), decodeTransactionReceipt, decodeEvent, decodeResource and decodeUtxo.
List recent transactions
Section titled “List recent transactions”Query recent transactions from the indexer:
const result = await provider.listRecentTransactions({ limit: 5, last_id: null });
for (const tx of result.transactions) { console.log(tx.transaction_id, tx.created_at);}Get a transaction result
Section titled “Get a transaction result”After submitting a transaction, you can poll for its result:
const result = await provider.getTransactionResult(transactionId);This is used internally by watchTransaction, but you can call it directly for custom polling logic.