[][src]Trait elrond_wasm::ContractHookApi

pub trait ContractHookApi<BigInt, BigUint>: Sized where
    BigInt: Encode + 'static,
    BigUint: Encode + 'static, 
{ fn get_sc_address(&self) -> Address;
fn get_owner_address(&self) -> Address;
fn get_caller(&self) -> Address;
fn get_balance(&self, address: &Address) -> BigUint;
fn storage_store(&self, key: &[u8], value: &[u8]);
fn storage_load(&self, key: &[u8]) -> Vec<u8>;
fn storage_load_len(&self, key: &[u8]) -> usize;
fn storage_store_bytes32(&self, key: &[u8], value: &[u8; 32]);
fn storage_load_bytes32(&self, key: &[u8]) -> [u8; 32];
fn storage_store_big_uint(&self, key: &[u8], value: &BigUint);
fn storage_load_big_uint(&self, key: &[u8]) -> BigUint;
fn storage_store_big_int(&self, key: &[u8], value: &BigInt);
fn storage_load_big_int(&self, key: &[u8]) -> BigInt;
fn storage_store_i64(&self, key: &[u8], value: i64);
fn storage_load_i64(&self, key: &[u8]) -> Option<i64>;
fn get_call_value_big_uint(&self) -> BigUint;
fn send_tx(&self, to: &Address, amount: &BigUint, message: &str);
fn async_call(&self, to: &Address, amount: &BigUint, data: &[u8]);
fn get_tx_hash(&self) -> H256;
fn get_gas_left(&self) -> i64;
fn get_block_timestamp(&self) -> u64;
fn get_block_nonce(&self) -> u64;
fn get_block_round(&self) -> u64;
fn get_block_epoch(&self) -> u64;
fn sha256(&self, data: &[u8]) -> [u8; 32];
fn keccak256(&self, data: &[u8]) -> [u8; 32]; fn get_sc_balance(&self) -> BigUint { ... }
fn storage_load_cumulated_validator_reward(&self) -> BigUint { ... } }

Interface to be used by the actual smart contract code.

Note: contracts and the api are not mutable. They simply pass on/retrieve data to/from the protocol. When mocking the blockchain state, we use the Rc/RefCell pattern to isolate mock state mutability from the contract interface.

Required methods

fn get_sc_address(&self) -> Address

fn get_owner_address(&self) -> Address

fn get_caller(&self) -> Address

fn get_balance(&self, address: &Address) -> BigUint

fn storage_store(&self, key: &[u8], value: &[u8])

fn storage_load(&self, key: &[u8]) -> Vec<u8>

fn storage_load_len(&self, key: &[u8]) -> usize

fn storage_store_bytes32(&self, key: &[u8], value: &[u8; 32])

fn storage_load_bytes32(&self, key: &[u8]) -> [u8; 32]

fn storage_store_big_uint(&self, key: &[u8], value: &BigUint)

fn storage_load_big_uint(&self, key: &[u8]) -> BigUint

fn storage_store_big_int(&self, key: &[u8], value: &BigInt)

fn storage_load_big_int(&self, key: &[u8]) -> BigInt

fn storage_store_i64(&self, key: &[u8], value: i64)

fn storage_load_i64(&self, key: &[u8]) -> Option<i64>

fn get_call_value_big_uint(&self) -> BigUint

fn send_tx(&self, to: &Address, amount: &BigUint, message: &str)

fn async_call(&self, to: &Address, amount: &BigUint, data: &[u8])

fn get_tx_hash(&self) -> H256

fn get_gas_left(&self) -> i64

fn get_block_timestamp(&self) -> u64

fn get_block_nonce(&self) -> u64

fn get_block_round(&self) -> u64

fn get_block_epoch(&self) -> u64

fn sha256(&self, data: &[u8]) -> [u8; 32]

fn keccak256(&self, data: &[u8]) -> [u8; 32]

Loading content...

Provided methods

fn get_sc_balance(&self) -> BigUint

fn storage_load_cumulated_validator_reward(&self) -> BigUint

Loading content...

Implementors

Loading content...