EVM smart contracts on Bittensor
Full Ethereum virtual machine (EVM) compatibility is now available on subtensor (the blockchain in Bittensor). This allows users to:
- Deploy most EVM smart contracts on subtensor without changing the code
- Interact with deployed smart contracts on the subtensor blockchain
- Access standard Ethereum JSON-RPC methods from this EVM compatibility layer on Subtensor, Bittensor's substrate blockchain.
Before you proceed
Before you proceed to use EVM on subtensor, make a note of the following:
- EVM smart contract executes on subtensor: The EVM feature allows the subtensor blockchain to execute Ethereum-compatible smart contracts. Note that all operations performed by this new subtensor EVM feature are executed solely on the subtensor blockchain, not on the Ethereum blockchain.
- 1 TAO = 1e18 on subtensor EVM: While working with the subtensor EVM, 1 TAO should be written as 1 followed by 18 zeroes, i.e., 1e18. See this code example: https://github.com/opentensor/evm-bittensor/blob/main/examples/withdraw.js#L58.
Available Precompiles
The following precompiles are available on the Bittensor EVM:
Standard Ethereum Precompiles
ECRecover
(0x1) - Recover the address associated with the public key from elliptic curve signatureSha256
(0x2) - SHA-256 hash functionRipemd160
(0x3) - RIPEMD-160 hash functionIdentity
(0x4) - Identity function (returns input data)Modexp
(0x5) - Modular exponentiationSha3FIPS256
(0x400) - SHA3-256 hash function (FIPS variant)ECRecoverPublicKey
(0x401) - Recover the public key from an elliptic curve signature
Bittensor-Specific Precompiles
Ed25519Verify
- Verify Ed25519 signaturesBalanceTransfer
- Transfer TAO between accountsStakingPrecompileV2
(0x805) - Main staking operations including:addStake
- Add stake to a hotkeyremoveStake
- Remove stake from a hotkeymoveStake
- Move stake between hotkeystransferStake
- Transfer stake between coldkeysgetTotalColdkeyStake
- Get total stake for a coldkeygetTotalHotkeyStake
- Get total stake for a hotkeygetStake
- Get stake between specific hotkey and coldkeyaddProxy
- Add a proxy delegateremoveProxy
- Remove a proxy delegate
SubnetPrecompile
- Manage subnet operationsMetagraphPrecompile
- Interact with the metagraphNeuronPrecompile
- Manage neuron operations
Run the below tutorials to learn how to use the EVM feature on the Bittensor blockchain.
Transfer TAO between two H160 addresses
Learn how to transfer TAO between two Ethereum H160 addresses.
READ MORE