EvmApi

Trait EvmApi 

Source
pub trait EvmApi: Send + 'static {
Show 17 methods // Required methods fn get_bytes32( &mut self, key: B256, evm_api_gas_to_use: Gas, ) -> Result<(B256, Gas)>; fn cache_bytes32(&mut self, key: B256, value: B256) -> Result<Gas>; fn flush_storage_cache( &mut self, clear: bool, gas_left: Gas, ) -> Result<(Gas, UserOutcomeKind)>; fn get_transient_bytes32(&mut self, key: B256) -> Result<B256>; fn set_transient_bytes32( &mut self, key: B256, value: B256, ) -> Result<UserOutcomeKind>; fn contract_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, value: U256, ) -> Result<(u32, Gas, UserOutcomeKind)>; fn delegate_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, ) -> Result<(u32, Gas, UserOutcomeKind)>; fn static_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, ) -> Result<(u32, Gas, UserOutcomeKind)>; fn create1( &mut self, code: Vec<u8>, endowment: U256, gas: Gas, ) -> Result<(CreateResponse, u32, Gas)>; fn create2( &mut self, code: Vec<u8>, endowment: U256, salt: B256, gas: Gas, ) -> Result<(CreateResponse, u32, Gas)>; fn get_return_data(&self) -> Vec<u8> ; fn emit_log(&mut self, data: Vec<u8>, topics: u32) -> Result<()>; fn account_balance(&mut self, address: Address) -> Result<(U256, Gas)>; fn account_code( &mut self, arbos_version: u64, address: Address, gas_left: Gas, ) -> Result<(Vec<u8>, Gas)>; fn account_codehash(&mut self, address: Address) -> Result<(B256, Gas)>; fn add_pages(&mut self, pages: u16) -> Result<Gas>; fn capture_hostio( &mut self, name: &str, args: &[u8], outs: &[u8], start_ink: Ink, end_ink: Ink, );
}
Expand description

The EVM API trait that Stylus programs use to interact with EVM state.

This is the bridge between the WASM runtime and the EVM execution environment. Implementations are provided by the block executor.

Required Methods§

Source

fn get_bytes32( &mut self, key: B256, evm_api_gas_to_use: Gas, ) -> Result<(B256, Gas)>

Read a storage slot. Returns the value and access cost.

Source

fn cache_bytes32(&mut self, key: B256, value: B256) -> Result<Gas>

Cache a storage value for later flushing.

Source

fn flush_storage_cache( &mut self, clear: bool, gas_left: Gas, ) -> Result<(Gas, UserOutcomeKind)>

Flush the storage cache to EVM state.

Source

fn get_transient_bytes32(&mut self, key: B256) -> Result<B256>

Read a transient storage slot.

Source

fn set_transient_bytes32( &mut self, key: B256, value: B256, ) -> Result<UserOutcomeKind>

Write a transient storage slot.

Source

fn contract_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, value: U256, ) -> Result<(u32, Gas, UserOutcomeKind)>

Execute a CALL. Returns return data length, gas cost, and outcome.

Source

fn delegate_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, ) -> Result<(u32, Gas, UserOutcomeKind)>

Execute a DELEGATECALL.

Source

fn static_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, ) -> Result<(u32, Gas, UserOutcomeKind)>

Execute a STATICCALL.

Source

fn create1( &mut self, code: Vec<u8>, endowment: U256, gas: Gas, ) -> Result<(CreateResponse, u32, Gas)>

Deploy via CREATE.

Source

fn create2( &mut self, code: Vec<u8>, endowment: U256, salt: B256, gas: Gas, ) -> Result<(CreateResponse, u32, Gas)>

Deploy via CREATE2.

Source

fn get_return_data(&self) -> Vec<u8>

Get the return data from the last call.

Source

fn emit_log(&mut self, data: Vec<u8>, topics: u32) -> Result<()>

Emit a log with the given data and number of topics.

Source

fn account_balance(&mut self, address: Address) -> Result<(U256, Gas)>

Get an account’s balance. Returns balance and access cost.

Source

fn account_code( &mut self, arbos_version: u64, address: Address, gas_left: Gas, ) -> Result<(Vec<u8>, Gas)>

Get an account’s code. Returns code and access cost.

Source

fn account_codehash(&mut self, address: Address) -> Result<(B256, Gas)>

Get an account’s code hash. Returns hash and access cost.

Source

fn add_pages(&mut self, pages: u16) -> Result<Gas>

Determine cost of allocating additional WASM pages.

Source

fn capture_hostio( &mut self, name: &str, args: &[u8], outs: &[u8], start_ink: Ink, end_ink: Ink, )

Capture tracing information for host I/O calls.

Implementors§