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§
Sourcefn get_bytes32(
&mut self,
key: B256,
evm_api_gas_to_use: Gas,
) -> Result<(B256, Gas)>
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.
Sourcefn cache_bytes32(&mut self, key: B256, value: B256) -> Result<Gas>
fn cache_bytes32(&mut self, key: B256, value: B256) -> Result<Gas>
Cache a storage value for later flushing.
Sourcefn flush_storage_cache(
&mut self,
clear: bool,
gas_left: Gas,
) -> Result<(Gas, UserOutcomeKind)>
fn flush_storage_cache( &mut self, clear: bool, gas_left: Gas, ) -> Result<(Gas, UserOutcomeKind)>
Flush the storage cache to EVM state.
Sourcefn get_transient_bytes32(&mut self, key: B256) -> Result<B256>
fn get_transient_bytes32(&mut self, key: B256) -> Result<B256>
Read a transient storage slot.
Sourcefn set_transient_bytes32(
&mut self,
key: B256,
value: B256,
) -> Result<UserOutcomeKind>
fn set_transient_bytes32( &mut self, key: B256, value: B256, ) -> Result<UserOutcomeKind>
Write a transient storage slot.
Sourcefn contract_call(
&mut self,
contract: Address,
calldata: &[u8],
gas_left: Gas,
gas_req: Gas,
value: U256,
) -> Result<(u32, Gas, UserOutcomeKind)>
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.
Sourcefn delegate_call(
&mut self,
contract: Address,
calldata: &[u8],
gas_left: Gas,
gas_req: Gas,
) -> Result<(u32, Gas, UserOutcomeKind)>
fn delegate_call( &mut self, contract: Address, calldata: &[u8], gas_left: Gas, gas_req: Gas, ) -> Result<(u32, Gas, UserOutcomeKind)>
Execute a DELEGATECALL.
Sourcefn static_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)>
Execute a STATICCALL.
Sourcefn create1(
&mut self,
code: Vec<u8>,
endowment: U256,
gas: Gas,
) -> Result<(CreateResponse, u32, Gas)>
fn create1( &mut self, code: Vec<u8>, endowment: U256, gas: Gas, ) -> Result<(CreateResponse, u32, Gas)>
Deploy via CREATE.
Sourcefn create2(
&mut self,
code: Vec<u8>,
endowment: U256,
salt: B256,
gas: Gas,
) -> Result<(CreateResponse, u32, Gas)>
fn create2( &mut self, code: Vec<u8>, endowment: U256, salt: B256, gas: Gas, ) -> Result<(CreateResponse, u32, Gas)>
Deploy via CREATE2.
Sourcefn get_return_data(&self) -> Vec<u8> ⓘ
fn get_return_data(&self) -> Vec<u8> ⓘ
Get the return data from the last call.
Sourcefn emit_log(&mut self, data: Vec<u8>, topics: u32) -> Result<()>
fn emit_log(&mut self, data: Vec<u8>, topics: u32) -> Result<()>
Emit a log with the given data and number of topics.
Sourcefn account_balance(&mut self, address: Address) -> Result<(U256, Gas)>
fn account_balance(&mut self, address: Address) -> Result<(U256, Gas)>
Get an account’s balance. Returns balance and access cost.
Sourcefn account_code(
&mut self,
arbos_version: u64,
address: Address,
gas_left: Gas,
) -> Result<(Vec<u8>, Gas)>
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.
Sourcefn account_codehash(&mut self, address: Address) -> Result<(B256, Gas)>
fn account_codehash(&mut self, address: Address) -> Result<(B256, Gas)>
Get an account’s code hash. Returns hash and access cost.