pub trait SendApi: ErrorApi + Clone + Sized {
    type AmountType: BigUintApi + 'static;
    type ProxyBigInt: BigIntApi + 'static;
    type ProxyEllipticCurve: EllipticCurveApi<BigUint = Self::AmountType> + 'static;
    type ProxyStorage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static;

Show 26 methods // Required methods fn get_sc_address(&self) -> Address; fn get_gas_left(&self) -> u64; fn get_dct_token_data( &self, address: &Address, token: &TokenIdentifier, nonce: u64 ) -> DctTokenData<Self::AmountType>; fn direct_moax(&self, to: &Address, amount: &Self::AmountType, data: &[u8]); fn direct_moax_execute( &self, to: &Address, amount: &Self::AmountType, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>; fn direct_dct_execute( &self, to: &Address, token: &TokenIdentifier, amount: &Self::AmountType, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>; fn direct_dct_nft_execute( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>; fn async_call_raw( &self, to: &Address, amount: &Self::AmountType, data: &[u8] ) -> !; fn deploy_contract( &self, gas: u64, amount: &Self::AmountType, code: &BoxedBytes, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ) -> Option<Address>; fn deploy_from_source_contract( &self, gas: u64, amount: &Self::AmountType, source_contract_address: &Address, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ) -> Option<Address>; fn upgrade_contract( &self, sc_address: &Address, gas: u64, amount: &Self::AmountType, code: &BoxedBytes, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ); fn execute_on_dest_context_raw( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>; fn execute_on_dest_context_raw_custom_result_range<F>( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer, range_closure: F ) -> Vec<BoxedBytes> where F: FnOnce(usize, usize) -> (usize, usize); fn execute_on_dest_context_by_caller_raw( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>; fn execute_on_same_context_raw( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer ); fn storage_store_tx_hash_key(&self, data: &[u8]); fn storage_load_tx_hash_key(&self) -> BoxedBytes; fn call_local_dct_built_in_function( &self, gas: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>; // Provided methods fn direct( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, data: &[u8] ) { ... } fn async_call(&self, async_call: AsyncCall<Self>) -> ! { ... } fn transfer_dct_via_async_call( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, data: &[u8] ) -> ! { ... } fn change_owner_address( &self, child_sc_address: &Address, new_owner: &Address ) { ... } fn dct_local_mint( &self, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType ) { ... } fn dct_local_burn( &self, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType ) { ... } fn dct_nft_create<T: TopEncode>( &self, token: &TokenIdentifier, amount: &Self::AmountType, name: &BoxedBytes, royalties: &Self::AmountType, hash: &BoxedBytes, attributes: &T, uris: &[BoxedBytes] ) -> u64 { ... } fn sell_nft( &self, nft_id: &TokenIdentifier, nft_nonce: u64, nft_amount: &Self::AmountType, buyer: &Address, payment_token: &TokenIdentifier, payment_nonce: u64, payment_amount: &Self::AmountType ) -> Self::AmountType { ... }
}
Expand description

API that groups methods that either send MOAX or DCT, or that call other contracts.

Required Associated Types§

source

type AmountType: BigUintApi + 'static

The type of the payment arguments. Not named BigUint to avoid name collisions in types that implement multiple API traits.

source

type ProxyBigInt: BigIntApi + 'static

Not used by SendApi, but forwarded to the proxy traits.

source

type ProxyEllipticCurve: EllipticCurveApi<BigUint = Self::AmountType> + 'static

source

type ProxyStorage: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static

Not used by SendApi, but forwarded to the proxy traits.

Required Methods§

source

fn get_sc_address(&self) -> Address

Required for DCTNFTTransfer. Same as the implementation from BlockchainApi.

source

fn get_gas_left(&self) -> u64

To be used internally by the SendApi implementation. Do not use directly from contracts. It might be removed from this trait at some point or reworked.

source

fn get_dct_token_data( &self, address: &Address, token: &TokenIdentifier, nonce: u64 ) -> DctTokenData<Self::AmountType>

Used internally for sell_nft. Do not use directly from contracts.

source

fn direct_moax(&self, to: &Address, amount: &Self::AmountType, data: &[u8])

Sends MOAX to a given address, directly. Used especially for sending MOAX to regular accounts.

source

fn direct_moax_execute( &self, to: &Address, amount: &Self::AmountType, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>

Sends MOAX to an address (optionally) and executes like an async call, but without callback.

source

fn direct_dct_execute( &self, to: &Address, token: &TokenIdentifier, amount: &Self::AmountType, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>

Sends DCT to an address and executes like an async call, but without callback.

source

fn direct_dct_nft_execute( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>

Sends DCT NFT to an address and executes like an async call, but without callback.

source

fn async_call_raw( &self, to: &Address, amount: &Self::AmountType, data: &[u8] ) -> !

Sends an asynchronous call to another contract. Calling this method immediately terminates tx execution. Using it directly is generally discouraged.

The data is expected to be of the form functionName@<arg1-hex>@<arg2-hex>@.... Use a HexCallDataSerializer to prepare this field.

source

fn deploy_contract( &self, gas: u64, amount: &Self::AmountType, code: &BoxedBytes, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ) -> Option<Address>

Deploys a new contract in the same shard. Unlike async_call_raw, the deployment is synchronous and tx execution continues afterwards. Also unlike async_call_raw, it uses an argument buffer to pass arguments If the deployment fails, Option::None is returned

source

fn deploy_from_source_contract( &self, gas: u64, amount: &Self::AmountType, source_contract_address: &Address, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ) -> Option<Address>

Deploys a new contract in the same shard by re-using the code of an already deployed source contract. The deployment is done synchronously and the new contract’s address is returned. If the deployment fails, Option::None is returned

source

fn upgrade_contract( &self, sc_address: &Address, gas: u64, amount: &Self::AmountType, code: &BoxedBytes, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer )

Upgrades a child contract of the currently executing contract. The upgrade is synchronous, and the current transaction will fail if the upgrade fails. The child contract’s new init function will be called with the provided arguments

source

fn execute_on_dest_context_raw( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>

Same shard, in-line execution of another contract.

source

fn execute_on_dest_context_raw_custom_result_range<F>( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer, range_closure: F ) -> Vec<BoxedBytes>
where F: FnOnce(usize, usize) -> (usize, usize),

Same shard, in-line execution of another contract. Allows the contract to specify which result range to extract as sync call result. This is a workaround to handle nested sync calls. Please do not use this method unless there is absolutely no other option. Will be eliminated after some future Arwen hook redesign. range_closure takes the number of results before, the number of results after, and is expected to return the start index (inclusive) and end index (exclusive).

source

fn execute_on_dest_context_by_caller_raw( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>

source

fn execute_on_same_context_raw( &self, gas: u64, address: &Address, value: &Self::AmountType, function: &[u8], arg_buffer: &ArgBuffer )

source

fn storage_store_tx_hash_key(&self, data: &[u8])

Used to store data between async call and callback.

source

fn storage_load_tx_hash_key(&self) -> BoxedBytes

Used to store data between async call and callback.

source

fn call_local_dct_built_in_function( &self, gas: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>

Allows synchronously calling a local function by name. Execution is resumed afterwards. You should never have to call this function directly. Use the other specific methods instead.

Provided Methods§

source

fn direct( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, data: &[u8] )

Sends either MOAX, DCT or NFT to the target address, depending on the token identifier and nonce

source

fn async_call(&self, async_call: AsyncCall<Self>) -> !

Sends an asynchronous call to another contract, with either MOAX or DCT value. The token argument decides which one it will be. Calling this method immediately terminates tx execution.

source

fn transfer_dct_via_async_call( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, data: &[u8] ) -> !

Performs a simple DCT/NFT transfer, but via async call.
As with any async call, this immediately terminates the execution of the current call.
So only use as the last call in your endpoint.
If you want to perform multiple transfers, use self.send().direct() instead.
Note that MOAX can NOT be transfered with this function.

source

fn change_owner_address(&self, child_sc_address: &Address, new_owner: &Address)

source

fn dct_local_mint( &self, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType )

Allows synchronous minting of DCT/SFT (depending on nonce). Execution is resumed afterwards. Note that the SC must have the DCTLocalMint or DCTNftAddQuantity roles set, or this will fail with “action is not allowed” For SFTs, you must use self.send().dct_nft_create() before adding additional quantity. This function cannot be used for NFTs.

source

fn dct_local_burn( &self, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType )

Allows synchronous burning of DCT/SFT/NFT (depending on nonce). Execution is resumed afterwards. Note that the SC must have the DCTLocalBurn or DCTNftBurn roles set, or this will fail with “action is not allowed”

source

fn dct_nft_create<T: TopEncode>( &self, token: &TokenIdentifier, amount: &Self::AmountType, name: &BoxedBytes, royalties: &Self::AmountType, hash: &BoxedBytes, attributes: &T, uris: &[BoxedBytes] ) -> u64

Creates a new NFT token of a certain type (determined by token_identifier).
attributes can be any serializable custom struct.
This is a built-in function, so the smart contract execution is resumed after. Must have DCTNftCreate role set, or this will fail with “action is not allowed”. Returns the nonce of the newly created NFT.

source

fn sell_nft( &self, nft_id: &TokenIdentifier, nft_nonce: u64, nft_amount: &Self::AmountType, buyer: &Address, payment_token: &TokenIdentifier, payment_nonce: u64, payment_amount: &Self::AmountType ) -> Self::AmountType

Sends thr NFTs to the buyer address and calculates and sends the required royalties to the NFT creator. Returns the payment amount left after sending royalties.

Object Safety§

This trait is not object safe.

Implementors§