[][src]Trait elrond_wasm::ContractHookApi

pub trait ContractHookApi<BigInt, BigUint>: Sized where
    BigInt: NestedEncode + 'static,
    BigUint: NestedEncode + '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_slice_u8(&self, key: &[u8], value: &[u8]);
fn storage_load_len(&self, key: &[u8]) -> usize;
fn storage_load_vec_u8(&self, key: &[u8]) -> Vec<u8>;
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_uint_raw(&self, key: &[u8], handle: i32);
fn storage_load_big_uint_raw(&self, key: &[u8]) -> i32;
fn storage_store_big_int(&self, key: &[u8], value: &BigInt);
fn storage_load_big_int(&self, key: &[u8]) -> BigInt;
fn storage_store_u64(&self, key: &[u8], value: u64);
fn storage_store_i64(&self, key: &[u8], value: i64);
fn storage_load_u64(&self, key: &[u8]) -> u64;
fn storage_load_i64(&self, key: &[u8]) -> i64;
fn get_call_value_big_uint(&self) -> BigUint;
fn get_esdt_value_big_uint(&self) -> BigUint;
fn get_esdt_token_name(&self) -> Vec<u8>;
fn send_tx(&self, to: &Address, amount: &BigUint, data: &[u8]);
fn async_call(&self, to: &Address, amount: &BigUint, data: &[u8]);
fn deploy_contract(
        &self,
        gas: u64,
        amount: &BigUint,
        code: &BoxedBytes,
        code_metadata: CodeMetadata,
        arg_buffer: &ArgBuffer
    ) -> Address;
fn get_tx_hash(&self) -> H256;
fn get_gas_left(&self) -> u64;
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 get_block_random_seed(&self) -> Box<[u8; 48]>

Notable traits for Box<I, A>

impl<I, A> Iterator for Box<I, A> where
    A: Allocator,
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
    A: Allocator + 'static,
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
;
fn get_prev_block_timestamp(&self) -> u64;
fn get_prev_block_nonce(&self) -> u64;
fn get_prev_block_round(&self) -> u64;
fn get_prev_block_epoch(&self) -> u64;
fn get_prev_block_random_seed(&self) -> Box<[u8; 48]>

Notable traits for Box<I, A>

impl<I, A> Iterator for Box<I, A> where
    A: Allocator,
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
    A: Allocator + 'static,
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
;
fn execute_on_dest_context(
        &self,
        gas: u64,
        address: &Address,
        value: &BigUint,
        function: &[u8],
        arg_buffer: &ArgBuffer
    );
fn execute_on_dest_context_by_caller(
        &self,
        gas: u64,
        address: &Address,
        value: &BigUint,
        function: &[u8],
        arg_buffer: &ArgBuffer
    );
fn execute_on_same_context(
        &self,
        gas: u64,
        address: &Address,
        value: &BigUint,
        function: &[u8],
        arg_buffer: &ArgBuffer
    );
fn sha256(&self, data: &[u8]) -> H256;
fn keccak256(&self, data: &[u8]) -> H256;
fn verify_bls(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool;
fn verify_ed25519(
        &self,
        key: &[u8],
        message: &[u8],
        signature: &[u8]
    ) -> bool;
fn verify_secp256k1(
        &self,
        key: &[u8],
        message: &[u8],
        signature: &[u8]
    ) -> bool; fn get_sc_balance(&self) -> BigUint { ... }
fn storage_load_boxed_bytes(&self, key: &[u8]) -> BoxedBytes { ... }
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[src]

fn get_owner_address(&self) -> Address[src]

fn get_caller(&self) -> Address[src]

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

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

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

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

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

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

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

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

fn storage_store_big_uint_raw(&self, key: &[u8], handle: i32)[src]

fn storage_load_big_uint_raw(&self, key: &[u8]) -> i32[src]

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

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

fn storage_store_u64(&self, key: &[u8], value: u64)[src]

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

fn storage_load_u64(&self, key: &[u8]) -> u64[src]

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

fn get_call_value_big_uint(&self) -> BigUint[src]

fn get_esdt_value_big_uint(&self) -> BigUint[src]

fn get_esdt_token_name(&self) -> Vec<u8>[src]

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

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

fn deploy_contract(
    &self,
    gas: u64,
    amount: &BigUint,
    code: &BoxedBytes,
    code_metadata: CodeMetadata,
    arg_buffer: &ArgBuffer
) -> Address
[src]

fn get_tx_hash(&self) -> H256[src]

fn get_gas_left(&self) -> u64[src]

fn get_block_timestamp(&self) -> u64[src]

fn get_block_nonce(&self) -> u64[src]

fn get_block_round(&self) -> u64[src]

fn get_block_epoch(&self) -> u64[src]

fn get_block_random_seed(&self) -> Box<[u8; 48]>

Notable traits for Box<I, A>

impl<I, A> Iterator for Box<I, A> where
    A: Allocator,
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
    A: Allocator + 'static,
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
[src]

fn get_prev_block_timestamp(&self) -> u64[src]

fn get_prev_block_nonce(&self) -> u64[src]

fn get_prev_block_round(&self) -> u64[src]

fn get_prev_block_epoch(&self) -> u64[src]

fn get_prev_block_random_seed(&self) -> Box<[u8; 48]>

Notable traits for Box<I, A>

impl<I, A> Iterator for Box<I, A> where
    A: Allocator,
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
    A: Allocator + 'static,
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;
[src]

fn execute_on_dest_context(
    &self,
    gas: u64,
    address: &Address,
    value: &BigUint,
    function: &[u8],
    arg_buffer: &ArgBuffer
)
[src]

fn execute_on_dest_context_by_caller(
    &self,
    gas: u64,
    address: &Address,
    value: &BigUint,
    function: &[u8],
    arg_buffer: &ArgBuffer
)
[src]

fn execute_on_same_context(
    &self,
    gas: u64,
    address: &Address,
    value: &BigUint,
    function: &[u8],
    arg_buffer: &ArgBuffer
)
[src]

fn sha256(&self, data: &[u8]) -> H256[src]

fn keccak256(&self, data: &[u8]) -> H256[src]

fn verify_bls(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool[src]

fn verify_ed25519(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool[src]

fn verify_secp256k1(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool[src]

Loading content...

Provided methods

fn get_sc_balance(&self) -> BigUint[src]

fn storage_load_boxed_bytes(&self, key: &[u8]) -> BoxedBytes[src]

fn storage_load_cumulated_validator_reward(&self) -> BigUint[src]

Loading content...

Implementors

Loading content...