Smart Contracts with EVM
Smart contract evaluation has launched on Bittensor
Smart Contracts
Smart contracts are agreements that are codified in code. When two (or more) parties wish to execute a smart contract, they agree on the terms, and write those terms into code - the smart contract. Upon completion of the smart contract provisions, the contract is executed.
EVM - Ethereum Virtual Machine
EVM is used to execute smart contracts. Generally, this is done on the ethereum blockchain, but in the case of Bittensor, these are run solely on the Bittensor subtensor chain. It allows developers to write and deploy smart contracts in programming languages like Solidity.
It should be noted that EVM is not native to substrate blockchains (like Bittensor.). To enable EVM and smart contracts to be run on Bittensor, an EVM implementation was added.
Once you have created and compiled a smart contract, it must be deployed on the Ethereum network.
Once a contract is deployed on the subtensor, any user can call and interact with the contract.
Executing a Smart Contract on Bittensor
A standard Bittensor wallet (your coldkey) is unable to execute smart contracts. Your coldkey wallet is controlled on the Bittensor side of the network (you have your password and 12 word mnemonic of the Bittensor chain).
In order to create a smart contract, you must have an EVM Bittensor wallet.
Create a Bittensor MetaMask coldkey wallet
Inside the MetaMask browser extension, create a new account. Add a network manually:
Network name: "Subtensor"
New RPC URL: wss://evm.chain.opentensor.ai (wss://test.finney.opentensor.ai:443 for test)
Chain ID: 945 (This is UTF-8 encoding for Alpha character)
Currency symbol: TAO
EVM wallet/ Substrate wallet interactions
With a EVM MetaMask wallet - you can execute smart contracts. Your EVM wallet has no functionality on the Bittensor network (it cannot transfer funds, stake, etc.)
Your Bittensor wallet cannot execute smart contracts.
So how do these two types of wallets interact?
EVM wallets on Bittensor
Your EVM wallet (in Metamask) can execute smart contracts. It has an alias address in Bittensor that can receive funds from "regular" Substrate wallets. This bittensor 'alias' has no password on the Bittensor side, and cannot be used for any transactions on the Bittensor chain. Any funds that are transferred into the alias immediately appear in the EVM wallet.
Bittensor wallets on EVM
In a similar way, Bittensor wallets have an alias address on EVM that can receive funds. This EVM 'alias' has no password and cannot be used to execute smart contracts on EVM, but can receive transfers or the execution of smart contracts.
1 tao = 1e18 in Bittensor EVM.
Due to the precision of token in EVM, 1 tao is written as (1 billion)^2.
Creating and executing Smart Contracts
the Opentensor Foundation has up to date guides on running smart contracts on Bittensor:
Updated about 5 hours ago