Skip to content

Commit d3d0c16

Browse files
committed
feat(iota-transaction-builder): improve send_coins docs
1 parent 09b159b commit d3d0c16

File tree

1 file changed

+36
-0
lines changed
  • crates/iota-transaction-builder/src/builder

1 file changed

+36
-0
lines changed

crates/iota-transaction-builder/src/builder/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,42 @@ impl<C, L> TransactionBuilder<C, L> {
379379

380380
/// Transfer some coins to a recipient address. If multiple coins are
381381
/// provided then they will be merged.
382+
///
383+
/// The `amount` parameter specifies the quantity in NANOS, where 1 IOTA
384+
/// equals 1_000_000_000 NANOS.
385+
/// If `amount` is provided, that amount is split from the provided coins
386+
/// and sent.
387+
/// If `amount` is `None`, the entire coins are transferred.
388+
///
389+
/// # Example
390+
///
391+
/// ```rust
392+
/// use iota_graphql_client::Client;
393+
/// use iota_transaction_builder::TransactionBuilder;
394+
/// use iota_types::{Address, ObjectId};
395+
///
396+
/// #[tokio::main(flavor = "current_thread")]
397+
/// async fn main() -> eyre::Result<()> {
398+
/// let client = Client::new_devnet();
399+
/// let from_address = Address::from_hex(
400+
/// "0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c",
401+
/// )?;
402+
/// let to_address = Address::from_hex(
403+
/// "0x0000a4984bd495d4346fa208ddff4f5d5e5ad48c21dec631ddebc99809f16900",
404+
/// )?;
405+
///
406+
/// // This is a coin of type
407+
/// // 0x3358bea865960fea2a1c6844b6fc365f662463dd1821f619838eb2e606a53b6a::cert::CERT
408+
/// let coin = ObjectId::from_hex(
409+
/// "0x8ef4259fa2a3499826fa4b8aebeb1d8e478cf5397d05361c96438940b43d28c9",
410+
/// )?;
411+
///
412+
/// let mut builder = TransactionBuilder::new(from_address).with_client(client);
413+
/// builder.send_coins([coin], to_address, 50000000000u64);
414+
/// let txn = builder.finish().await?;
415+
/// Ok(())
416+
/// }
417+
/// ```
382418
pub fn send_coins<T: PTBArgumentList, U: PTBArgument>(
383419
&mut self,
384420
coins: T,

0 commit comments

Comments
 (0)