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
impl TransferTransaction
sourcepub fn hbar_transfer(
&mut self,
account_id: AccountId,
amount: Hbar
) -> &mut Self
pub fn hbar_transfer( &mut self, account_id: AccountId, amount: Hbar ) -> &mut Self
Add a non-approved hbar transfer to the transaction.
sourcepub fn approved_hbar_transfer(
&mut self,
account_id: AccountId,
amount: Hbar
) -> &mut Self
pub fn approved_hbar_transfer( &mut self, account_id: AccountId, amount: Hbar ) -> &mut Self
Add an approved hbar transfer to the transaction.
sourcepub fn get_hbar_transfers(&self) -> HashMap<AccountId, Hbar>
pub fn get_hbar_transfers(&self) -> HashMap<AccountId, Hbar>
Returns all transfers associated with this transaction.
sourcepub fn token_transfer(
&mut self,
token_id: TokenId,
account_id: AccountId,
amount: i64
) -> &mut Self
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).
sourcepub fn approved_token_transfer(
&mut self,
token_id: TokenId,
account_id: AccountId,
amount: i64
) -> &mut Self
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).
sourcepub fn token_transfer_with_decimals(
&mut self,
token_id: TokenId,
account_id: AccountId,
amount: i64,
expected_decimals: u32
) -> &mut Self
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
.
sourcepub fn approved_token_transfer_with_decimals(
&mut self,
token_id: TokenId,
account_id: AccountId,
amount: i64,
expected_decimals: u32
) -> &mut Self
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
.
sourcepub fn get_token_transfers(&self) -> HashMap<TokenId, HashMap<AccountId, i64>>
pub fn get_token_transfers(&self) -> HashMap<TokenId, HashMap<AccountId, i64>>
Returns all the token transfers associated associated with this transaction.
sourcepub fn get_token_decimals(&self) -> HashMap<TokenId, u32>
pub fn get_token_decimals(&self) -> HashMap<TokenId, u32>
Returns the decimals associated with each token.
sourcepub fn approved_nft_transfer(
&mut self,
nft_id: impl Into<NftId>,
sender_account_id: AccountId,
receiver_account_id: AccountId
) -> &mut Self
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.
sourcepub fn nft_transfer(
&mut self,
nft_id: impl Into<NftId>,
sender_account_id: AccountId,
receiver_account_id: AccountId
) -> &mut Self
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.
sourcepub fn get_nft_transfers(&self) -> HashMap<TokenId, Vec<TokenNftTransfer>>
pub fn get_nft_transfers(&self) -> HashMap<TokenId, Vec<TokenNftTransfer>>
Returns all the NFT transfers associated with this transaction.