BaseFee docs
Look up any call, event, or storage item with code examples. Runtime v472 · Block #9,197,056
Developer documentation for the BaseFee 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.
BaseFee
Calls 2
Manually sets the EIP-1559 base fee (admin only).
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
fee | U256 | — | fee: 256-bit unsigned integer (Ethereum-style) |
// ----------------------------------------------------------------------
// 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_base_fee_per_gas call (typed, named args)
const fee = undefined as any /* U256 — replace with real value */;
const tx = api.tx.BaseFee.set_base_fee_per_gas({
fee,
});Sets the base fee elasticity parameter (admin only).
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
elasticity | Permill | — | elasticity: Per-million ratio (0..1,000,000) |
// ----------------------------------------------------------------------
// 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_elasticity call (typed, named args)
const elasticity = undefined as any /* Permill — replace with real value */;
const tx = api.tx.BaseFee.set_elasticity({
elasticity,
});Events 3
Emitted when the EIP-1559 base fee is updated.
When it fires
- Block finalization
- Fee calculation complete
Fields
| Name | Type | Format | Description |
|---|---|---|---|
base_fee | U256 | — | New base fee per gas in wei (U256) |
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 NewBaseFeePerGas events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.BaseFee.NewBaseFeePerGas.get(block.hash);
for (const evt of events) {
console.log("NewBaseFeePerGas:", evt.payload);
}
});Emitted when base fee calculation would overflow.
When it fires
- Fee calculation attempted
- Result exceeds max
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 BaseFeeOverflow events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.BaseFee.BaseFeeOverflow.get(block.hash);
for (const evt of events) {
console.log("BaseFeeOverflow:", evt.payload);
}
});Emitted when base fee elasticity parameter is updated.
When it fires
- Admin call
- Valid elasticity value
Fields
| Name | Type | Format | Description |
|---|---|---|---|
elasticity | Permill | — | New elasticity value (Permill) |
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 NewElasticity events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.BaseFee.NewElasticity.get(block.hash);
for (const evt of events) {
console.log("NewElasticity:", evt.payload);
}
});Storage 2
The current EIP-1559 base fee in wei.
U256 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 BaseFeePerGas storage (no keys - plain value)
const result = await api.query.BaseFee.BaseFeePerGas.getValue();
console.log("BaseFeePerGas:", result);The base fee elasticity multiplier.
Permill 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 Elasticity storage (no keys - plain value)
const result = await api.query.BaseFee.Elasticity.getValue();
console.log("Elasticity:", result);