Write EVM contract using Rust.
-
Generate EVM bytecode from Rust code.
-
Contract compostion.
-
Call contract in contract.
-
Follow the soldity ABI and call convention.
-
Generate ABI.
-
Generate client SDK.
-
Core library.
- FFI
- Warpped Function
- UInt
- BytesN
- SInt
- Address
- Add
AsRef
andAsMut
- Add From
- Add
TryFrom
- Add "UnsafeFrom" and
UnsafeInto
- Memory
-
Std
- Selector
- ABI
- Contract
- Context
- Msg
- Transaction
- Block
-
Macros
- Contract
- uint!
- Event
- AbiEncode, AbiDecode
- Function Call
Install cargo-evm
by cargo binstall
.
cargo binstall cargo-evm
Create project using the following command:
cargo evm new "<your-project-name>"
Please add your contract file under src
. We use simple store contract as example.
use patine::{storage::{Value, Storage}, U256};
#[contract]
pub struct Contract {
value: Value<U256, Storage>,
}
#[contract]
impl Contract {
#[expose]
pub fn store(&mut self, value: U256) {
self.value.set(value)
}
#[expose]
pub fn load() -> U256 {
self.value.get()
}
}