Bittensor EVM: Examples and Precompiles
Available Precompiles
The following precompiled smart contracts are available on the Bittensor EVM. The source code can be found on GitHub.
Code examples used throughout are provided by OTF, and come from this repository.
Install the EVM Examples repo
- Clone the Opentensor EVM-Bittensor GitHub repo:
git clone https://github.com/opentensor/evm-bittensor.git
- Navigate to
evm-bittensor
directory:cd evm-bittensor
- Install the dependencies:
npm install
Examples
- Convert Ethereum (H160) Address to Substrate (SS58): Learn how to convert between H160 and SS58 address formats
- Converting Between Ethereum and Substrate Addresses: Learn how to convert between H160 and SS58 address formats
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 accountsStakingPrecompile
: Manage staking operationsStakingPrecompileV2
(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