pub struct SendWrapper<A>{ /* private fields */ }
Expand description
API that groups methods that either send EGLD or ESDT, or that call other contracts.
Implementations§
Source§impl<A> SendWrapper<A>
impl<A> SendWrapper<A>
pub fn new() -> Self
Sourcepub fn esdt_system_sc_proxy(
&self,
) -> ESDTSystemSCProxyMethods<TxScEnv<A>, (), ESDTSystemSCAddress, ()>
pub fn esdt_system_sc_proxy( &self, ) -> ESDTSystemSCProxyMethods<TxScEnv<A>, (), ESDTSystemSCAddress, ()>
Backwards compatibility, synonymous to esdt_system_sc_tx
, which is the more appropriate name now.
Sourcepub fn esdt_system_sc_tx(
&self,
) -> ESDTSystemSCProxyMethods<TxScEnv<A>, (), ESDTSystemSCAddress, ()>
pub fn esdt_system_sc_tx( &self, ) -> ESDTSystemSCProxyMethods<TxScEnv<A>, (), ESDTSystemSCAddress, ()>
Prepares a proxy object to call the ESDT system SC. It has the destination address set, as well as the contract type (as specified in the proxy).
Sourcepub fn contract_call<R>(
&self,
to: ManagedAddress<A>,
endpoint_name: impl Into<ManagedBuffer<A>>,
) -> ContractCallNoPayment<A, R>
pub fn contract_call<R>( &self, to: ManagedAddress<A>, endpoint_name: impl Into<ManagedBuffer<A>>, ) -> ContractCallNoPayment<A, R>
Convenient way to quickly instance a minimal contract call (with no EGLD, no arguments, etc.)
You can further configure this contract call by chaining methods to it.
Sourcepub fn direct_egld(&self, to: &ManagedAddress<A>, amount: &BigUint<A>)
pub fn direct_egld(&self, to: &ManagedAddress<A>, amount: &BigUint<A>)
Sends EGLD to a given address, directly. Used especially for sending EGLD to regular accounts.
Sourcepub fn direct_non_zero_egld(&self, to: &ManagedAddress<A>, amount: &BigUint<A>)
pub fn direct_non_zero_egld(&self, to: &ManagedAddress<A>, amount: &BigUint<A>)
Sends EGLD to a given address, directly. Used especially for sending EGLD to regular accounts.
If the amount is 0, it returns without error.
Sourcepub fn direct(
&self,
to: &ManagedAddress<A>,
token: &EgldOrEsdtTokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
)
pub fn direct( &self, to: &ManagedAddress<A>, token: &EgldOrEsdtTokenIdentifier<A>, nonce: u64, amount: &BigUint<A>, )
Sends either EGLD, ESDT or NFT to the target address, depending on the token identifier and nonce
Sourcepub fn direct_non_zero(
&self,
to: &ManagedAddress<A>,
token: &EgldOrEsdtTokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
)
pub fn direct_non_zero( &self, to: &ManagedAddress<A>, token: &EgldOrEsdtTokenIdentifier<A>, nonce: u64, amount: &BigUint<A>, )
Sends either EGLD, ESDT or NFT to the target address, depending on the token identifier and nonce.
If the amount is 0, it returns without error.
Sourcepub fn direct_esdt_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token_identifier: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
pub fn direct_esdt_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token_identifier: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
Sends a single ESDT transfer, and calls an endpoint at the destination.
Avoid if possible, use a contract call with ESDT transfer instead, and call .transfer_execute()
on it.
Sourcepub fn direct_non_zero_esdt_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token_identifier: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
pub fn direct_non_zero_esdt_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token_identifier: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
Sends a single ESDT transfer, and calls an endpoint at the destination.
If the amount is 0, it returns without error.
Avoid if possible, use a contract call with ESDT transfer instead, and call .transfer_execute()
on it.
Sourcepub fn direct_esdt(
&self,
to: &ManagedAddress<A>,
token_identifier: &TokenIdentifier<A>,
token_nonce: u64,
amount: &BigUint<A>,
)
pub fn direct_esdt( &self, to: &ManagedAddress<A>, token_identifier: &TokenIdentifier<A>, token_nonce: u64, amount: &BigUint<A>, )
Sends a single ESDT transfer to target address.
Sourcepub fn direct_non_zero_esdt_payment(
&self,
to: &ManagedAddress<A>,
payment: &EsdtTokenPayment<A>,
)
pub fn direct_non_zero_esdt_payment( &self, to: &ManagedAddress<A>, payment: &EsdtTokenPayment<A>, )
Sends a single ESDT transfer to target address.
If the amount is 0, it returns without error.
Sourcepub fn direct_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token: &EgldOrEsdtTokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
pub fn direct_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token: &EgldOrEsdtTokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
Sends either EGLD, ESDT or NFT to the target address, depending on the token identifier and nonce. Also and calls an endpoint at the destination.
Avoid if possible, use a contract call with ESDT transfer instead, and call .transfer_execute()
on it.
Sourcepub fn direct_non_zero_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token: &EgldOrEsdtTokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
pub fn direct_non_zero_with_gas_limit<D>(
&self,
to: &ManagedAddress<A>,
token: &EgldOrEsdtTokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
gas: u64,
endpoint_name: D,
arguments: &[ManagedBuffer<A>],
)where
D: Into<ManagedBuffer<A>>,
Sends either EGLD, ESDT or NFT to the target address, depending on the token identifier and nonce. Also and calls an endpoint at the destination.
If the amount is 0, it returns without error.
Avoid if possible, use a contract call with ESDT transfer instead, and call .transfer_execute()
on it.
Sourcepub fn direct_multi(
&self,
to: &ManagedAddress<A>,
payments: &ManagedVec<A, EsdtTokenPayment<A>>,
)
pub fn direct_multi( &self, to: &ManagedAddress<A>, payments: &ManagedVec<A, EsdtTokenPayment<A>>, )
Sends multiple ESDT tokens to a target address.
Sourcepub fn transfer_esdt_via_async_call(
&self,
to: ManagedAddress<A>,
token: TokenIdentifier<A>,
nonce: u64,
amount: BigUint<A>,
) -> !
pub fn transfer_esdt_via_async_call( &self, to: ManagedAddress<A>, token: TokenIdentifier<A>, nonce: u64, amount: BigUint<A>, ) -> !
Performs a simple ESDT/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().transfer_multiple_esdt_via_async_call()
instead.
Note that EGLD can NOT be transfered with this function.
Sourcepub fn transfer_esdt_non_zero_via_async_call(
&self,
to: ManagedAddress<A>,
token: TokenIdentifier<A>,
nonce: u64,
amount: BigUint<A>,
)
pub fn transfer_esdt_non_zero_via_async_call( &self, to: ManagedAddress<A>, token: TokenIdentifier<A>, nonce: u64, amount: BigUint<A>, )
Performs a simple ESDT/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().transfer_multiple_esdt_via_async_call()
instead.
Note that EGLD can NOT be transfered with this function.
If the amount is 0, it returns without error.
Sourcepub fn transfer_multiple_esdt_via_async_call(
&self,
to: ManagedAddress<A>,
payments: ManagedVec<A, EsdtTokenPayment<A>>,
) -> !
pub fn transfer_multiple_esdt_via_async_call( &self, to: ManagedAddress<A>, payments: ManagedVec<A, EsdtTokenPayment<A>>, ) -> !
Sends multiple ESDT tokens to a target address, via an async call.
Sourcepub fn claim_developer_rewards(
&self,
child_sc_address: ManagedAddress<A>,
) -> Tx<TxScEnv<A>, (), ManagedAddress<A>, NotPayable, (), FunctionCall<A>, OriginalResultMarker<()>>
pub fn claim_developer_rewards( &self, child_sc_address: ManagedAddress<A>, ) -> Tx<TxScEnv<A>, (), ManagedAddress<A>, NotPayable, (), FunctionCall<A>, OriginalResultMarker<()>>
Creates a call to the ClaimDeveloperRewards
builtin function.
Sourcepub fn change_owner_address(
&self,
child_sc_address: ManagedAddress<A>,
new_owner: &ManagedAddress<A>,
) -> Tx<TxScEnv<A>, (), ManagedAddress<A>, NotPayable, (), FunctionCall<A>, OriginalResultMarker<()>>
pub fn change_owner_address( &self, child_sc_address: ManagedAddress<A>, new_owner: &ManagedAddress<A>, ) -> Tx<TxScEnv<A>, (), ManagedAddress<A>, NotPayable, (), FunctionCall<A>, OriginalResultMarker<()>>
Creates a call to the ChangeOwnerAddress
builtin function.
Sourcepub fn call_local_esdt_built_in_function(
&self,
gas: u64,
endpoint_name: ManagedBuffer<A>,
arg_buffer: ManagedArgBuffer<A>,
) -> ManagedVec<A, ManagedBuffer<A>>
pub fn call_local_esdt_built_in_function( &self, gas: u64, endpoint_name: ManagedBuffer<A>, arg_buffer: ManagedArgBuffer<A>, ) -> ManagedVec<A, ManagedBuffer<A>>
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.
Sourcepub fn esdt_local_mint(
&self,
token: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
)
pub fn esdt_local_mint( &self, token: &TokenIdentifier<A>, nonce: u64, amount: &BigUint<A>, )
Allows synchronous minting of ESDT/SFT (depending on nonce). Execution is resumed afterwards.
Note that the SC must have the ESDTLocalMint or ESDTNftAddQuantity roles set, or this will fail with “action is not allowed”.
For SFTs, you must use self.send().esdt_nft_create()
before adding additional quantity.
This function cannot be used for NFTs.
Sourcepub fn esdt_non_zero_local_mint(
&self,
token: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
)
pub fn esdt_non_zero_local_mint( &self, token: &TokenIdentifier<A>, nonce: u64, amount: &BigUint<A>, )
Allows synchronous minting of ESDT/SFT (depending on nonce). Execution is resumed afterwards.
Note that the SC must have the ESDTLocalMint or ESDTNftAddQuantity roles set, or this will fail with “action is not allowed”.
For SFTs, you must use self.send().esdt_nft_create()
before adding additional quantity.
This function cannot be used for NFTs.
If the amount is 0, it returns without error.
Sourcepub fn esdt_local_burn(
&self,
token: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
)
pub fn esdt_local_burn( &self, token: &TokenIdentifier<A>, nonce: u64, amount: &BigUint<A>, )
Allows synchronous burning of ESDT/SFT/NFT (depending on nonce). Execution is resumed afterwards.
Note that the SC must have the ESDTLocalBurn or ESDTNftBurn roles set, or this will fail with “action is not allowed”.
Sourcepub fn esdt_non_zero_local_burn(
&self,
token: &TokenIdentifier<A>,
nonce: u64,
amount: &BigUint<A>,
)
pub fn esdt_non_zero_local_burn( &self, token: &TokenIdentifier<A>, nonce: u64, amount: &BigUint<A>, )
Allows synchronous burning of ESDT/SFT/NFT (depending on nonce). Execution is resumed afterwards.
Note that the SC must have the ESDTLocalBurn or ESDTNftBurn roles set, or this will fail with “action is not allowed”.
If the amount is 0, it returns without error.
Sourcepub fn esdt_local_burn_multi(
&self,
payments: &ManagedVec<A, EsdtTokenPayment<A>>,
)
pub fn esdt_local_burn_multi( &self, payments: &ManagedVec<A, EsdtTokenPayment<A>>, )
Allows burning of multiple ESDT tokens at once.
Will execute a synchronous call to the appropriate burn builtin function for each.
Sourcepub fn esdt_non_zero_local_burn_multi(
&self,
payments: &ManagedVec<A, EsdtTokenPayment<A>>,
)
pub fn esdt_non_zero_local_burn_multi( &self, payments: &ManagedVec<A, EsdtTokenPayment<A>>, )
Allows burning of multiple ESDT tokens at once.
Will execute a synchronous call to the appropriate burn builtin function for each.
If any of the token amounts is 0 skips that token without throwing error.
Sourcepub fn esdt_nft_create<T: TopEncode>(
&self,
token: &TokenIdentifier<A>,
amount: &BigUint<A>,
name: &ManagedBuffer<A>,
royalties: &BigUint<A>,
hash: &ManagedBuffer<A>,
attributes: &T,
uris: &ManagedVec<A, ManagedBuffer<A>>,
) -> u64
pub fn esdt_nft_create<T: TopEncode>( &self, token: &TokenIdentifier<A>, amount: &BigUint<A>, name: &ManagedBuffer<A>, royalties: &BigUint<A>, hash: &ManagedBuffer<A>, attributes: &T, uris: &ManagedVec<A, ManagedBuffer<A>>, ) -> u64
Creates a new NFT token of a certain type (determined by token_identifier
).
attributes
can be any serializable custom struct.
This is a synchronous built-in function call, so the smart contract execution is resumed afterwards.
Must have ESDTNftCreate role set, or this will fail with “action is not allowed”.
Returns the nonce of the newly created NFT.
Sourcepub fn esdt_non_zero_nft_create<T: TopEncode>(
&self,
token: &TokenIdentifier<A>,
amount: &BigUint<A>,
name: &ManagedBuffer<A>,
royalties: &BigUint<A>,
hash: &ManagedBuffer<A>,
attributes: &T,
uris: &ManagedVec<A, ManagedBuffer<A>>,
) -> u64
pub fn esdt_non_zero_nft_create<T: TopEncode>( &self, token: &TokenIdentifier<A>, amount: &BigUint<A>, name: &ManagedBuffer<A>, royalties: &BigUint<A>, hash: &ManagedBuffer<A>, attributes: &T, uris: &ManagedVec<A, ManagedBuffer<A>>, ) -> 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 ESDTNftCreate role set, or this will fail with “action is not allowed”.
Returns the nonce of the newly created NFT.
If the amount is 0, it returns without error.
Sourcepub fn esdt_nft_create_compact<T: TopEncode>(
&self,
token: &TokenIdentifier<A>,
amount: &BigUint<A>,
attributes: &T,
) -> u64
pub fn esdt_nft_create_compact<T: TopEncode>( &self, token: &TokenIdentifier<A>, amount: &BigUint<A>, attributes: &T, ) -> u64
Quick way of creating a new NFT token instance.
Returns the new NFT nonce.
Sourcepub fn esdt_nft_create_compact_named<T: TopEncode>(
&self,
token: &TokenIdentifier<A>,
amount: &BigUint<A>,
name: &ManagedBuffer<A>,
attributes: &T,
) -> u64
pub fn esdt_nft_create_compact_named<T: TopEncode>( &self, token: &TokenIdentifier<A>, amount: &BigUint<A>, name: &ManagedBuffer<A>, attributes: &T, ) -> u64
Quick way of creating a new NFT token instance, with custom name.
Returns the new NFT nonce.
Sourcepub fn esdt_non_zero_nft_create_compact<T: TopEncode>(
&self,
token: &TokenIdentifier<A>,
amount: &BigUint<A>,
attributes: &T,
) -> u64
pub fn esdt_non_zero_nft_create_compact<T: TopEncode>( &self, token: &TokenIdentifier<A>, amount: &BigUint<A>, attributes: &T, ) -> u64
Quick way of creating a new NFT token instance.
Returns the new NFT nonce.
If the amount is 0, it returns without error.
Sourcepub fn esdt_non_zero_nft_create_compact_named<T: TopEncode>(
&self,
token: &TokenIdentifier<A>,
amount: &BigUint<A>,
name: &ManagedBuffer<A>,
attributes: &T,
) -> u64
pub fn esdt_non_zero_nft_create_compact_named<T: TopEncode>( &self, token: &TokenIdentifier<A>, amount: &BigUint<A>, name: &ManagedBuffer<A>, attributes: &T, ) -> u64
Quick way of creating a new NFT token instance, with custom name.
Returns the new NFT nonce.
If the amount is 0, it returns without error.
Sourcepub fn sell_nft(
&self,
nft_id: &TokenIdentifier<A>,
nft_nonce: u64,
nft_amount: &BigUint<A>,
buyer: &ManagedAddress<A>,
payment_token: &EgldOrEsdtTokenIdentifier<A>,
payment_nonce: u64,
payment_amount: &BigUint<A>,
) -> BigUint<A>
pub fn sell_nft( &self, nft_id: &TokenIdentifier<A>, nft_nonce: u64, nft_amount: &BigUint<A>, buyer: &ManagedAddress<A>, payment_token: &EgldOrEsdtTokenIdentifier<A>, payment_nonce: u64, payment_amount: &BigUint<A>, ) -> BigUint<A>
Sends the NFTs to the buyer address and calculates and sends the required royalties to the NFT creator.
Returns the payment amount left after sending royalties.
Sourcepub fn sell_nft_non_zero(
&self,
nft_id: &TokenIdentifier<A>,
nft_nonce: u64,
nft_amount: &BigUint<A>,
buyer: &ManagedAddress<A>,
payment_token: &EgldOrEsdtTokenIdentifier<A>,
payment_nonce: u64,
payment_amount: &BigUint<A>,
) -> BigUint<A>
pub fn sell_nft_non_zero( &self, nft_id: &TokenIdentifier<A>, nft_nonce: u64, nft_amount: &BigUint<A>, buyer: &ManagedAddress<A>, payment_token: &EgldOrEsdtTokenIdentifier<A>, payment_nonce: u64, payment_amount: &BigUint<A>, ) -> BigUint<A>
Sends the NFTs to the buyer address and calculates and sends the required royalties to the NFT creator.
Returns the payment amount left after sending royalties.
If the nft_amount or the payment_amount is 0 returns without error
Sourcepub fn nft_add_uri(
&self,
token_id: &TokenIdentifier<A>,
nft_nonce: u64,
new_uri: ManagedBuffer<A>,
)
pub fn nft_add_uri( &self, token_id: &TokenIdentifier<A>, nft_nonce: u64, new_uri: ManagedBuffer<A>, )
Adds a new URI to an NFT, via a synchronous builtin function call.
Sourcepub fn nft_add_multiple_uri(
&self,
token_id: &TokenIdentifier<A>,
nft_nonce: u64,
new_uris: &ManagedVec<A, ManagedBuffer<A>>,
)
pub fn nft_add_multiple_uri( &self, token_id: &TokenIdentifier<A>, nft_nonce: u64, new_uris: &ManagedVec<A, ManagedBuffer<A>>, )
Adds a multiple URIs to an NFT, via a synchronous builtin function call.
Sourcepub fn nft_update_attributes<T: TopEncode>(
&self,
token_id: &TokenIdentifier<A>,
nft_nonce: u64,
new_attributes: &T,
)
pub fn nft_update_attributes<T: TopEncode>( &self, token_id: &TokenIdentifier<A>, nft_nonce: u64, new_attributes: &T, )
Changes attributes of an NFT, via a synchronous builtin function call.
Sourcepub fn esdt_modify_royalties(
&self,
token_id: &TokenIdentifier<A>,
nonce: u64,
new_royalty: u64,
)
pub fn esdt_modify_royalties( &self, token_id: &TokenIdentifier<A>, nonce: u64, new_royalty: u64, )
Modifies royalties for a specific token.
Sourcepub fn esdt_nft_set_new_uris(
&self,
token_id: &TokenIdentifier<A>,
nonce: u64,
uris: &ManagedVec<A, ManagedBuffer<A>>,
)
pub fn esdt_nft_set_new_uris( &self, token_id: &TokenIdentifier<A>, nonce: u64, uris: &ManagedVec<A, ManagedBuffer<A>>, )
Sets new uris for a specific token.
Sourcepub fn esdt_nft_modify_creator(&self, token_id: &TokenIdentifier<A>, nonce: u64)
pub fn esdt_nft_modify_creator(&self, token_id: &TokenIdentifier<A>, nonce: u64)
Changes the creator of a specific token into the caller.
Sourcepub fn esdt_metadata_recreate<T: TopEncode>(
&self,
token_id: TokenIdentifier<A>,
nonce: u64,
name: ManagedBuffer<A>,
royalties: u64,
hash: ManagedBuffer<A>,
new_attributes: &T,
uris: ManagedVec<A, ManagedBuffer<A>>,
)
pub fn esdt_metadata_recreate<T: TopEncode>( &self, token_id: TokenIdentifier<A>, nonce: u64, name: ManagedBuffer<A>, royalties: u64, hash: ManagedBuffer<A>, new_attributes: &T, uris: ManagedVec<A, ManagedBuffer<A>>, )
Recreates an ESDT token with the newly specified attributes.
Sourcepub fn esdt_metadata_update<T: TopEncode>(
&self,
token_id: TokenIdentifier<A>,
nonce: u64,
name: ManagedBuffer<A>,
royalties: u64,
hash: ManagedBuffer<A>,
new_attributes: &T,
uris: ManagedVec<A, ManagedBuffer<A>>,
)
pub fn esdt_metadata_update<T: TopEncode>( &self, token_id: TokenIdentifier<A>, nonce: u64, name: ManagedBuffer<A>, royalties: u64, hash: ManagedBuffer<A>, new_attributes: &T, uris: ManagedVec<A, ManagedBuffer<A>>, )
Updates an ESDT token with the newly specified attributes.