Commitments docs
Look up any call, event, or storage item with code examples. Runtime v472 · Block #9,197,056
Developer documentation for the Commitments pallet of the Subtensor blockchain, part of the Bittensor decentralized AI network. This page is designed for developers integrating with the chain: look up any call, event, or storage item, copy code examples in TypeScript, Python, or Rust, and filter by your role. For in-depth explanations, version history, and relationships between items, see the Reference section.
Commitments
Set the commitment for a given netuid
Calls 2
Stores on-chain commitment data for an account on a specific subnet.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
netuid | NetUid | — | netuid: Subnet ID (u16, 0-65535) |
info | CommitmentInfo | — | info (CommitmentInfo) |
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Build set_commitment call (typed, named args)
const netuid = 1;
const info = undefined as any /* CommitmentInfo — replace with real value */;
const tx = api.tx.Commitments.set_commitment({
netuid,
info,
});Sets the maximum commitment space per account (sudo only).
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
new_limit | u32 | Integer | new_limit (u32) |
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Build set_max_space call (typed, named args)
const new_limit = 0;
const tx = api.tx.Commitments.set_max_space({
new_limit,
});Events 4
Emitted when an account sets a commitment for a subnet.
When it fires
- Account is registered on the subnet
- Commitment data within size limits
Fields
| Name | Type | Format | Description |
|---|---|---|---|
netuid | NetUid | — | Subnet ID where commitment was made |
account | AccountId | SS58 Address | Account that set the commitment |
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Subscribe to Commitment events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.Commitments.Commitment.get(block.hash);
for (const evt of events) {
console.log("Commitment:", evt.payload);
}
});Emitted when an account sets a timelocked commitment.
When it fires
- Account is registered on the subnet
- Commitment includes timelocked fields with future reveal round
Fields
| Name | Type | Format | Description |
|---|---|---|---|
netuid | NetUid | — | Subnet ID where timelocked commitment was made |
account | AccountId | SS58 Address | Account that set the timelocked commitment |
reveal_round | u64 | Integer | Drand beacon round when data will auto-reveal |
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Subscribe to TimelockCommitment events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.Commitments.TimelockCommitment.get(block.hash);
for (const evt of events) {
console.log("TimelockCommitment:", evt.payload);
}
});Emitted when a timelocked commitment is auto-revealed.
When it fires
- Timelocked commitment exists for the account/subnet
- Drand reveal round has been reached
- Decryption successful with drand beacon entropy
Fields
| Name | Type | Format | Description |
|---|---|---|---|
netuid | NetUid | — | Subnet ID where commitment was revealed |
account | AccountId | SS58 Address | Account whose commitment was revealed |
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Subscribe to CommitmentRevealed events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.Commitments.CommitmentRevealed.get(block.hash);
for (const evt of events) {
console.log("CommitmentRevealed:", evt.payload);
}
});Emitted when a timelock-encrypted commitment could not be revealed and was left in place.
When it fires
- A timelocked commitment exists for the account and subnet
- The runtime attempted the reveal for that drand round
- Either the drand round has aged past the oldest round the chain still keeps, or decryption of the field failed
Fields
| Name | Type | Format | Description |
|---|---|---|---|
netuid | NetUid | — | netuid: Subnet ID (u16, 0-65535) |
who | AccountId | SS58 Address | who: Account address (32 bytes, SS58-encoded) |
reveal_round | u64 | Integer | reveal_round (u64) |
error | RevealFailure | — | error (RevealFailure) |
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Subscribe to CommitmentRevealFailed events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.Commitments.CommitmentRevealFailed.get(block.hash);
for (const evt of events) {
console.log("CommitmentRevealFailed:", evt.payload);
}
});Storage 8
Stores commitment data for an account on a specific subnet.
Registration Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | NetUid | — | — |
key2 | AccountId | SS58 Address | — |
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query CommitmentOf storage
const key1 = undefined as any /* NetUid — replace with real value */;
const key2 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const result = await api.query.Commitments.CommitmentOf.getValue(key1, key2);
console.log("CommitmentOf:", result);Block number of the last bonds reset for an account on a subnet.
u32 (Integer)Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | NetUid | — | — |
key2 | AccountId | SS58 Address | — |
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query LastBondsReset storage
const key1 = undefined as any /* NetUid — replace with real value */;
const key2 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const result = await api.query.Commitments.LastBondsReset.getValue(key1, key2);
console.log("LastBondsReset:", result);Block number of the last commitment update for an account on a subnet.
u32 (Integer)Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | NetUid | — | — |
key2 | AccountId | SS58 Address | — |
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query LastCommitment storage
const key1 = undefined as any /* NetUid — replace with real value */;
const key2 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const result = await api.query.Commitments.LastCommitment.getValue(key1, key2);
console.log("LastCommitment:", result);Maximum commitment space per account per rate limit interval.
u32 (Integer)import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query MaxSpace storage (no keys - plain value)
const result = await api.query.Commitments.MaxSpace.getValue();
console.log("MaxSpace:", result);Stores revealed timelocked commitment data after auto-reveal.
Vec<(Vec<u8>, u64)> (Array of (Vec<u8>, u64))Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | NetUid | — | — |
key2 | AccountId | SS58 Address | — |
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query RevealedCommitments storage
const key1 = undefined as any /* NetUid — replace with real value */;
const key2 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const result = await api.query.Commitments.RevealedCommitments.getValue(key1, key2);
console.log("RevealedCommitments:", result);Tracks all commitments that have timelocked fields pending reveal.
BTreeSet import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query TimelockedIndex storage (no keys - plain value)
const result = await api.query.Commitments.TimelockedIndex.getValue();
console.log("TimelockedIndex:", result);Where the last timelock reveal pass stopped when it ran out of decryption budget.
(NetUid, AccountId) import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query TimelockRevealCursor storage (no keys - plain value)
const result = await api.query.Commitments.TimelockRevealCursor.getValue();
console.log("TimelockRevealCursor:", result);Tracks commitment space usage for rate limiting.
UsageTracker Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | NetUid | — | — |
key2 | AccountId | SS58 Address | — |
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running — the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query UsedSpaceOf storage
const key1 = undefined as any /* NetUid — replace with real value */;
const key2 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const result = await api.query.Commitments.UsedSpaceOf.getValue(key1, key2);
console.log("UsedSpaceOf:", result);Constants 3
Additional deposit per field in commitment.
TaoBalance"0"import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query FieldDeposit constant
const value = await api.constants.Commitments.FieldDeposit();
console.log("FieldDeposit:", value);
// Balance: divide by 10^9 for TAO
const tao = value / 1_000_000_000n;Deposit required to register a commitment identity.
TaoBalance"0"import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query InitialDeposit constant
const value = await api.constants.Commitments.InitialDeposit();
console.log("InitialDeposit:", value);
// Balance: divide by 10^9 for TAO
const tao = value / 1_000_000_000n;Maximum number of additional fields in a commitment.
u323import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Query MaxFields constant
const value = await api.constants.Commitments.MaxFields();
console.log("MaxFields:", value);Errors 5
Your commitment contains more fields than the maximum allowed.
Common Causes
- Trying to include too many data fields in commitment
- Exceeding MaxFields constant
How to Fix
Check Commitments.MaxFields constant for the limit,Reduce the number of fields in your commitment
Your account is not allowed to make commitments to this subnet.
Common Causes
- Account not registered on the subnet
- Subnet has commitment restrictions
How to Fix
Register on the subnet first,Check if subnet allows public commitments
You've exceeded your commitment space quota for this interval.
Common Causes
- Committing too much data too quickly
- Commitment data size exceeds MaxSpace
How to Fix
Wait for rate limit window to reset,Reduce commitment data size,Check UsedSpaceOf for current usage
An internal error occurred when unreserving deposit funds.
Common Causes
- Rare edge case in deposit accounting
- Chain state inconsistency
How to Fix
Retry the operation,Report if persistent
The submitted commitment contains a TimelockRevealFailed field. Only the runtime creates those, so an extrinsic carrying one is rejected.
Common Causes
- Reading an existing commitment, modifying part of it, and resubmitting the whole structure including a runtime-written failure marker
- Round-tripping commitment data through a client that treats every Data variant as user-settable
How to Fix
Strip any TimelockRevealFailed field before resubmitting,Build the commitment from the fields you intend to set rather than from a previous read,Submit fresh timelocked data as a TimelockEncrypted field if the earlier reveal failed