EVM docs
Look up any call, event, or storage item with code examples. Runtime v490 · Block #9,478,217
Developer documentation for the EVM 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.
EVM
Withdraw balance from EVM into currency/balances pallet.
Calls 7
Withdraws balance from an EVM account to the Substrate balance.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
address | H160 | 160-bit Hash | address: 20-byte address (Ethereum-style) |
value | TaoBalance | — | value: Balance in chain native currency (RAO for TAO; ÷10⁹) |
// ----------------------------------------------------------------------
// 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 withdraw call (typed, named args)
const address = "0x0000000000000000000000000000000000000000";
const value = undefined as any /* TaoBalance — replace with real value */;
const tx = api.tx.EVM.withdraw({
address,
value,
});Issues an EVM call operation like an Ethereum message call.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
source | H160 | 160-bit Hash | source: 20-byte address (Ethereum-style) |
target | H160 | 160-bit Hash | target: 20-byte address (Ethereum-style) |
input | Vec<u8> | Array of Integer (0-255) | input (Vec<u8>) |
value | U256 | — | value: 256-bit unsigned integer (Ethereum-style) |
gas_limit | u64 | Integer | gas_limit (u64) |
max_fee_per_gas | U256 | — | max_fee_per_gas: 256-bit unsigned integer (Ethereum-style) |
max_priority_fee_per_gas | Option | — | max_priority_fee_per_gas: optional 256-bit unsigned integer (Ethereum-style) |
nonce | Option | — | nonce: optional 256-bit unsigned integer (Ethereum-style) |
access_list | Vec<(H160, Vec<H256>)> | Array of (H160, Vec<H256>) | access_list (Vec<(H160, Vec<H256>)>) |
authorization_list | Vec<AuthorizationListItem> | Array of AuthorizationListItem | authorization_list (Vec<AuthorizationListItem>) |
// ----------------------------------------------------------------------
// HEADS UP: 2 args below have a complex type with no usable default.
// Look for `undefined as any` and replace them with real values
// 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 call call (typed, named args)
const source = "0x0000000000000000000000000000000000000000";
const target = "0x0000000000000000000000000000000000000000";
const input = Binary.fromOpaque(new Uint8Array(0));
const value = undefined as any /* U256 — replace with real value */;
const gas_limit = 0n;
const max_fee_per_gas = undefined as any /* U256 — replace with real value */;
const max_priority_fee_per_gas = undefined;
const nonce = undefined;
const access_list = [] as [];
const authorization_list = [] as [];
const tx = api.tx.EVM.call({
source,
target,
input,
value,
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
access_list,
authorization_list,
});Deploys a new smart contract using CREATE opcode logic.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
source | H160 | 160-bit Hash | source: 20-byte address (Ethereum-style) |
init | Vec<u8> | Array of Integer (0-255) | init (Vec<u8>) |
value | U256 | — | value: 256-bit unsigned integer (Ethereum-style) |
gas_limit | u64 | Integer | gas_limit (u64) |
max_fee_per_gas | U256 | — | max_fee_per_gas: 256-bit unsigned integer (Ethereum-style) |
max_priority_fee_per_gas | Option | — | max_priority_fee_per_gas: optional 256-bit unsigned integer (Ethereum-style) |
nonce | Option | — | nonce: optional 256-bit unsigned integer (Ethereum-style) |
access_list | Vec<(H160, Vec<H256>)> | Array of (H160, Vec<H256>) | access_list (Vec<(H160, Vec<H256>)>) |
authorization_list | Vec<AuthorizationListItem> | Array of AuthorizationListItem | authorization_list (Vec<AuthorizationListItem>) |
// ----------------------------------------------------------------------
// HEADS UP: 2 args below have a complex type with no usable default.
// Look for `undefined as any` and replace them with real values
// 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 create call (typed, named args)
const source = "0x0000000000000000000000000000000000000000";
const init = Binary.fromOpaque(new Uint8Array(0));
const value = undefined as any /* U256 — replace with real value */;
const gas_limit = 0n;
const max_fee_per_gas = undefined as any /* U256 — replace with real value */;
const max_priority_fee_per_gas = undefined;
const nonce = undefined;
const access_list = [] as [];
const authorization_list = [] as [];
const tx = api.tx.EVM.create({
source,
init,
value,
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
access_list,
authorization_list,
});Deploys a contract using CREATE2 for deterministic addressing.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
source | H160 | 160-bit Hash | source: 20-byte address (Ethereum-style) |
init | Vec<u8> | Array of Integer (0-255) | init (Vec<u8>) |
salt | H256 | 256-bit Hash | salt: 32-byte hash (Ethereum-compatible) |
value | U256 | — | value: 256-bit unsigned integer (Ethereum-style) |
gas_limit | u64 | Integer | gas_limit (u64) |
max_fee_per_gas | U256 | — | max_fee_per_gas: 256-bit unsigned integer (Ethereum-style) |
max_priority_fee_per_gas | Option | — | max_priority_fee_per_gas: optional 256-bit unsigned integer (Ethereum-style) |
nonce | Option | — | nonce: optional 256-bit unsigned integer (Ethereum-style) |
access_list | Vec<(H160, Vec<H256>)> | Array of (H160, Vec<H256>) | access_list (Vec<(H160, Vec<H256>)>) |
authorization_list | Vec<AuthorizationListItem> | Array of AuthorizationListItem | authorization_list (Vec<AuthorizationListItem>) |
// ----------------------------------------------------------------------
// HEADS UP: 2 args below have a complex type with no usable default.
// Look for `undefined as any` and replace them with real values
// 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 create2 call (typed, named args)
const source = "0x0000000000000000000000000000000000000000";
const init = Binary.fromOpaque(new Uint8Array(0));
const salt = "0x0000000000000000000000000000000000000000000000000000000000000000";
const value = undefined as any /* U256 — replace with real value */;
const gas_limit = 0n;
const max_fee_per_gas = undefined as any /* U256 — replace with real value */;
const max_priority_fee_per_gas = undefined;
const nonce = undefined;
const access_list = [] as [];
const authorization_list = [] as [];
const tx = api.tx.EVM.create2({
source,
init,
salt,
value,
gas_limit,
max_fee_per_gas,
max_priority_fee_per_gas,
nonce,
access_list,
authorization_list,
});Sets the list of addresses allowed to deploy contracts.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
new | Vec<H160> | Array of 160-bit Hash | new: list of 20-byte address (Ethereum-style) |
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_whitelist call (typed, named args)
const new_ = [] as [];
const tx = api.tx.EVM.set_whitelist({
new: new_,
});Enables or disables the contract deployment whitelist.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
disabled | bool | Boolean (true/false) | disabled (bool) |
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 disable_whitelist call (typed, named args)
const disabled = true;
const tx = api.tx.EVM.disable_whitelist({
disabled,
});Transfers TAO from the signer to the Substrate account that backs an EVM address, resolving the address mapping when the call executes.
Parameters
| Name | Type | Format | Description |
|---|---|---|---|
address | H160 | 160-bit Hash | address: 20-byte address (Ethereum-style) |
value | Option | — | value: optional Balance in chain native currency (RAO for TAO; ÷10⁹) |
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 deposit call (typed, named args)
const address = "0x0000000000000000000000000000000000000000";
const value = undefined;
const tx = api.tx.EVM.deposit({
address,
value,
});Events 5
Emitted when an Ethereum smart contract emits a log event.
When it fires
- Smart contract is executing
- Contract calls LOG opcode
Fields
| Name | Type | Format | Description |
|---|---|---|---|
log | Log | — | Ethereum log entry containing address, topics, and data |
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 Log events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.EVM.Log.get(block.hash);
for (const evt of events) {
console.log("Log:", evt.payload);
}
});Emitted when a new smart contract is deployed to the EVM.
When it fires
- Valid bytecode
- Sufficient gas
- Creator whitelisted if required
Fields
| Name | Type | Format | Description |
|---|---|---|---|
contract_address | H160 | 160-bit Hash | Address of the newly deployed contract (H160) |
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 Created events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.EVM.Created.get(block.hash);
for (const evt of events) {
console.log("Created:", evt.payload);
}
});Emitted when contract creation fails during execution.
When it fires
- Creation attempted
- Execution error occurred
Fields
| Name | Type | Format | Description |
|---|---|---|---|
intended_address | H160 | 160-bit Hash | Address where contract would have been deployed (H160) |
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 CreatedFailed events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.EVM.CreatedFailed.get(block.hash);
for (const evt of events) {
console.log("CreatedFailed:", evt.payload);
}
});Emitted when a contract call succeeds with state changes applied.
When it fires
- Contract exists
- Valid call data
- Sufficient gas
Fields
| Name | Type | Format | Description |
|---|---|---|---|
contract_address | H160 | 160-bit Hash | Address of the executed contract (H160) |
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 Executed events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.EVM.Executed.get(block.hash);
for (const evt of events) {
console.log("Executed:", evt.payload);
}
});Emitted when a contract call fails, reverting state but consuming gas.
When it fires
- Call attempted
- Error or revert occurred
Fields
| Name | Type | Format | Description |
|---|---|---|---|
contract_address | H160 | 160-bit Hash | Address of the contract that failed (H160) |
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 ExecutedFailed events
client.finalizedBlock$.subscribe(async (block) => {
const events = await api.event.EVM.ExecutedFailed.get(block.hash);
for (const evt of events) {
console.log("ExecutedFailed:", evt.payload);
}
});Storage 6
Maps EVM addresses to their deployed contract bytecode.
Vec<u8> (Array of Integer (0-255))Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | H160 | 160-bit Hash | — |
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 AccountCodes storage
const key1 = "0x0000000000000000000000000000000000000000";
const result = await api.query.EVM.AccountCodes.getValue(key1);
console.log("AccountCodes:", result);Metadata about contract code (size, hash).
CodeMetadata Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | H160 | 160-bit Hash | — |
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 AccountCodesMetadata storage
const key1 = "0x0000000000000000000000000000000000000000";
const result = await api.query.EVM.AccountCodesMetadata.getValue(key1);
console.log("AccountCodesMetadata:", result);Per account, the EVM transaction nonce retained independently of the System account, so a reaped and refunded account cannot reuse old nonces.
u32 (Integer)Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | AccountId | SS58 Address | — |
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 AccountNonces storage
const key1 = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const result = await api.query.EVM.AccountNonces.getValue(key1);
console.log("AccountNonces:", result);Per-contract storage slots (key-value pairs).
H256 (256-bit Hash)Keys
| Name | Type | Format | Description |
|---|---|---|---|
key1 | H160 | 160-bit Hash | — |
key2 | H256 | 256-bit Hash | — |
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 AccountStorages storage
const key1 = "0x0000000000000000000000000000000000000000";
const key2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
const result = await api.query.EVM.AccountStorages.getValue(key1, key2);
console.log("AccountStorages:", result);Whether the deployment whitelist is bypassed.
bool (Boolean (true/false))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 DisableWhitelistCheck storage (no keys - plain value)
const result = await api.query.EVM.DisableWhitelistCheck.getValue();
console.log("DisableWhitelistCheck:", result);List of addresses allowed to deploy contracts.
Vec<H160> (Array of 160-bit Hash)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 WhitelistedCreators storage (no keys - plain value)
const result = await api.query.EVM.WhitelistedCreators.getValue();
console.log("WhitelistedCreators:", result);Constants 1
Flag constant, always true, marking a runtime that has the EVM.deposit call.
booltrueimport { 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 NativeDepositSupported constant
const value = await api.constants.EVM.NativeDepositSupported();
console.log("NativeDepositSupported:", value);Errors 16
The EVM account doesn't have enough balance for this operation.
Common Causes
- Trying to send more value than account holds
- Insufficient funds for gas + value
- Balance depleted by previous operations
How to Fix
Check EVM account balance before transacting,Reduce value or gas limit,Transfer more funds to the EVM account
Calculating the total transaction fee caused an overflow.
Common Causes
- Extremely high gas price specified
- Gas limit times gas price exceeds safe bounds
How to Fix
Reduce gas price to reasonable levels,Lower the gas limit if possible
Total payment calculation (gas + value) overflowed.
Common Causes
- Extreme values for gas or transaction value
How to Fix
Use reasonable values for gas and transaction amount
Failed to withdraw fee from the sender's account.
Common Causes
- Balance changed between check and deduction
- Account locked or restricted
How to Fix
Retry the transaction,Check account status and locks
The gas price is below the minimum required.
Common Causes
- Gas price below base fee
- Gas price below network minimum
How to Fix
Increase gas price to at least the base fee,Check BaseFeePerGas for current minimum
The transaction nonce doesn't match expected.
Common Causes
- Nonce too low (already used)
- Nonce too high (gap in sequence)
- Transaction already submitted
How to Fix
Query the current nonce for your address,Use the next sequential nonce,Wait for pending transactions to confirm
The gas limit is insufficient for this operation.
Common Causes
- Gas limit below intrinsic gas (21000 for transfers)
- Complex operation needs more gas
How to Fix
Increase gas limit,Estimate gas using eth_estimateGas,Add buffer to gas estimate (e.g., 20%)
The gas limit exceeds the block gas limit.
Common Causes
- Gas limit set unreasonably high
How to Fix
Reduce gas limit to below block limit
The transaction chain ID doesn't match this network.
Common Causes
- Transaction signed for different network
- Wallet configured with wrong chain ID
How to Fix
Check EVMChainId.ChainId for correct value,Configure wallet with correct chain ID,Re-sign transaction with correct chain ID
The transaction signature verification failed.
Common Causes
- Transaction data modified after signing
- Signature malformed
- Wrong private key used
How to Fix
Re-sign the transaction,Verify private key matches expected address,Check for data corruption
EVM reentrancy detected - recursive call protection triggered.
Common Causes
- Contract attempting recursive calls through the pallet
How to Fix
Review contract for reentrancy patterns,Use reentrancy guards in contracts
Transaction origin must be an externally owned account, not a contract.
Common Causes
- Contract trying to initiate transactions directly
How to Fix
Ensure transactions originate from EOAs, not contracts
An undefined EVM error occurred.
Common Causes
- Unknown error condition in EVM execution
How to Fix
Check transaction traces for more details,Report if reproducible
The origin is not allowed to perform this operation.
Common Causes
- Caller lacks required permissions
How to Fix
Check required permissions for this call,Use authorized account
This address is not allowed to deploy contracts.
Common Causes
- Whitelist is enabled and address not on it
- Contract deployment restricted
How to Fix
Check WhitelistedCreators for allowed addresses,Request whitelist addition from admin,Wait for whitelist to be disabled
An EIP-7702 transaction carries more than 255 authorizations (MAX_AUTHORIZATION_LIST_SIZE).
Common Causes
- A batching client packed more than 255 delegation authorizations into one type-4 transaction
How to Fix
Split the authorizations across several transactions of at most 255 each