Skip to content

Commit 1caa681

Browse files
authored
Merge pull request #569 from hashgraph/sr/transfer-tx-doc
2 parents 67f2aa3 + 06e4750 commit 1caa681

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/transfer_transaction.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ use crate::{
5555
/// from the corresponding account (a sender), and each positive one is added to the corresponding
5656
/// account (a receiver). The amounts list must sum to zero.
5757
///
58+
/// All transfers are in the lowest denomination, for `Hbar` that is tinybars (although `Hbar` handles this itself).
59+
///
60+
/// As an example: for a fungible token with `3` decimals (and let's say the symbol is `ƒ`), transferring `1` _always_ transfers `0.001 ƒ`.
5861
pub type TransferTransaction = Transaction<TransferTransactionData>;
5962

6063
#[derive(Debug, Clone, Default)]
@@ -146,6 +149,8 @@ impl TransferTransaction {
146149
}
147150

148151
/// Add a non-approved token transfer to the transaction.
152+
///
153+
/// `amount` is in the lowest denomination for the token (if the token has `2` decimals this would be `0.01` tokens).
149154
pub fn token_transfer(
150155
&mut self,
151156
token_id: TokenId,
@@ -156,6 +161,8 @@ impl TransferTransaction {
156161
}
157162

158163
/// Add an approved token transfer to the transaction.
164+
///
165+
/// `amount` is in the lowest denomination for the token (if the token has `2` decimals this would be `0.01` tokens).
159166
pub fn approved_token_transfer(
160167
&mut self,
161168
token_id: TokenId,
@@ -165,7 +172,11 @@ impl TransferTransaction {
165172
self._token_transfer(token_id, account_id, amount, true, None)
166173
}
167174

168-
/// Add a non-approved token transfer with decimals to the transaction.
175+
// todo: make the examples into code, just not sure how to do that.
176+
/// Add a non-approved token transfer to the transaction, ensuring that the token has `expected_decimals` decimals.
177+
///
178+
/// `amount` is _still_ in the lowest denomination, however,
179+
/// you will get an error if the token has a different amount of decimals than `expected_decimals`.
169180
pub fn token_transfer_with_decimals(
170181
&mut self,
171182
token_id: TokenId,
@@ -176,7 +187,10 @@ impl TransferTransaction {
176187
self._token_transfer(token_id, account_id, amount, false, Some(expected_decimals))
177188
}
178189

179-
/// Add an approved token transfer with decimals to the transaction.
190+
/// Add an approved token transfer, ensuring that the token has `expected_decimals` decimals.
191+
///
192+
/// `amount` is _still_ in the lowest denomination, however,
193+
/// you will get an error if the token has a different amount of decimals than `expected_decimals`.
180194
pub fn approved_token_transfer_with_decimals(
181195
&mut self,
182196
token_id: TokenId,

0 commit comments

Comments
 (0)