Type Alias hedera::TransferTransaction

source ·
pub type TransferTransaction = Transaction<TransferTransactionData>;
Expand description

Transfers cryptocurrency among two or more accounts by making the desired adjustments to their balances.

Each transfer list can specify up to 10 adjustments. Each negative amount is withdrawn from the corresponding account (a sender), and each positive one is added to the corresponding account (a receiver). The amounts list must sum to zero.

All transfers are in the lowest denomination, for Hbar that is tinybars (although Hbar handles this itself).

As an example: for a fungible token with 3 decimals (and let’s say the symbol is ƒ), transferring 1 always transfers 0.001 ƒ.

Aliased Type§

struct TransferTransaction { /* private fields */ }

Implementations§

source§

impl TransferTransaction

source

pub fn hbar_transfer( &mut self, account_id: AccountId, amount: Hbar ) -> &mut Self

Add a non-approved hbar transfer to the transaction.

source

pub fn approved_hbar_transfer( &mut self, account_id: AccountId, amount: Hbar ) -> &mut Self

Add an approved hbar transfer to the transaction.

source

pub fn get_hbar_transfers(&self) -> HashMap<AccountId, Hbar>

Returns all transfers associated with this transaction.

source

pub fn token_transfer( &mut self, token_id: TokenId, account_id: AccountId, amount: i64 ) -> &mut Self

Add a non-approved token transfer to the transaction.

amount is in the lowest denomination for the token (if the token has 2 decimals this would be 0.01 tokens).

source

pub fn approved_token_transfer( &mut self, token_id: TokenId, account_id: AccountId, amount: i64 ) -> &mut Self

Add an approved token transfer to the transaction.

amount is in the lowest denomination for the token (if the token has 2 decimals this would be 0.01 tokens).

source

pub fn token_transfer_with_decimals( &mut self, token_id: TokenId, account_id: AccountId, amount: i64, expected_decimals: u32 ) -> &mut Self

Add a non-approved token transfer to the transaction, ensuring that the token has expected_decimals decimals.

amount is still in the lowest denomination, however, you will get an error if the token has a different amount of decimals than expected_decimals.

source

pub fn approved_token_transfer_with_decimals( &mut self, token_id: TokenId, account_id: AccountId, amount: i64, expected_decimals: u32 ) -> &mut Self

Add an approved token transfer, ensuring that the token has expected_decimals decimals.

amount is still in the lowest denomination, however, you will get an error if the token has a different amount of decimals than expected_decimals.

source

pub fn get_token_transfers(&self) -> HashMap<TokenId, HashMap<AccountId, i64>>

Returns all the token transfers associated associated with this transaction.

source

pub fn get_token_decimals(&self) -> HashMap<TokenId, u32>

Returns the decimals associated with each token.

source

pub fn approved_nft_transfer( &mut self, nft_id: impl Into<NftId>, sender_account_id: AccountId, receiver_account_id: AccountId ) -> &mut Self

Add an approved nft transfer to the transaction.

source

pub fn nft_transfer( &mut self, nft_id: impl Into<NftId>, sender_account_id: AccountId, receiver_account_id: AccountId ) -> &mut Self

Add a non-approved nft transfer to the transaction.

source

pub fn get_nft_transfers(&self) -> HashMap<TokenId, Vec<TokenNftTransfer>>

Returns all the NFT transfers associated with this transaction.