openethereum/src/evm/ext.rs

37 lines
1.1 KiB
Rust
Raw Normal View History

2016-01-09 21:39:38 +01:00
//! Interface for Evm externalities.
2015-12-30 12:46:10 +01:00
2015-12-23 13:02:01 +01:00
use util::hash::*;
2015-12-29 12:04:03 +01:00
use util::uint::*;
2016-01-06 13:00:14 +01:00
use util::bytes::*;
2016-01-09 00:51:09 +01:00
pub trait Ext {
2016-01-07 23:33:54 +01:00
/// Returns a value for given key.
fn sload(&self, key: &H256) -> H256;
/// Stores a value for given key.
fn sstore(&mut self, key: H256, value: H256);
/// Returns address balance.
fn balance(&self, address: &Address) -> U256;
/// Returns the hash of one of the 256 most recent complete blocks.
fn blockhash(&self, number: &U256) -> H256;
/// Creates new contract.
2016-01-09 23:24:01 +01:00
/// If contract creation is successfull,
/// returns new contract address and gas used,
/// otherwise `None`.
fn create(&mut self, gas: u64, endowment: &U256, code: &[u8]) -> Option<(Address, u64)>;
/// Message call.
/// If call is successfull, returns call output and gas used,
/// otherwise `None`.
2016-01-09 00:51:09 +01:00
fn call(&mut self, gas: u64, call_gas: u64, receive_address: &Address, value: &U256, data: &[u8], code_address: &Address) -> Option<(Vec<u8>, u64)>;
2016-01-07 23:33:54 +01:00
/// Returns code at given address
fn extcode(&self, address: &Address) -> Vec<u8>;
/// Creates log entry with given topics and data
fn log(&mut self, topics: Vec<H256>, data: Bytes);
}