InitialTxRateLimit

Constant v101 → current u64

Prevents spam and ensures fair access.

Current Value

1000
Relevant for: developersminersvalidators

The Big Picture

Some operations (like setting weights or serving info) could be spammed to game the system or DoS the network. This constant enforces a cooldown between such operations. It ensures fair access by preventing wealthy actors from monopolizing block space and gives the network time to process and propagate changes.

Why This Matters

Build rate limiting into your code. If you try to repeat a rate-limited operation too quickly, the transaction fails. Track your last operation block and wait appropriately.

Example

With TxRateLimit of 2 blocks for set_weights, after setting weights at block 1000, you must wait until block 1002 to set them again. Attempting at block 1001 fails with a rate limit error.

Common Questions

Does this apply to all transactions?
No, only specific operations like set_weights, serve_axon, etc. Normal transfers are not rate-limited beyond normal fee mechanics.
How do I know when I can retry?
Track the block of your last operation. Wait TxRateLimit blocks before retrying. Or catch the rate limit error and implement exponential backoff.

Use Cases

  • Transaction validation
  • Rate limiting

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Query InitialTxRateLimit constant
const value = api.consts[stringCamelCase("SubtensorModule")][stringCamelCase("InitialTxRateLimit")];
console.log("InitialTxRateLimit:", value.toHuman());

// Convert RAO to TAO if this is a balance value
const taoValue = value.toBigInt() / BigInt(1e9);
console.log("TAO:", taoValue.toString());

Type Information

Type
u64
Byte Size
8 bytes
Encoding
fixed
Raw Hex
0xe803000000000000

Runtime Info

Pallet
SubtensorModule
First Version
v101
Latest Version
v101
Current Runtime
v393