Skip to main content

Module sui::pay

This module provides handy functionality for wallets and sui::Coin management.

Constants

For when empty vector is supplied into join function.

const ENoCoins: u64 = 0;

Function keep

Transfer c to the sender of the current transaction

public fun keep<T>(c: sui::coin::Coin<T>, ctx: &sui::tx_context::TxContext)

Function split

Split coin to two coins, one with balance split_amount, and the remaining balance is left in coin.

public entry fun split<T>(coin: &mut sui::coin::Coin<T>, split_amount: u64, ctx: &mut sui::tx_context::TxContext)

Function split_vec

Split coin self into multiple coins, each with balance specified in split_amounts. Remaining balance is left in self.

public entry fun split_vec<T>(self: &mut sui::coin::Coin<T>, split_amounts: vector<u64>, ctx: &mut sui::tx_context::TxContext)

Function split_and_transfer

Send amount units of c to recipient.
Aborts with sui::balance::ENotEnough if amount is greater than the balance in c

public entry fun split_and_transfer<T>(c: &mut sui::coin::Coin<T>, amount: u64, recipient: address, ctx: &mut sui::tx_context::TxContext)

Function divide_and_keep

Divide coin self into n - 1 coins with equal balances. If the balance is not evenly divisible by n, the remainder is left in self.

public entry fun divide_and_keep<T>(self: &mut sui::coin::Coin<T>, n: u64, ctx: &mut sui::tx_context::TxContext)

Function join

Join coin into self. Re-exports coin::join function.
Deprecated: you should call coin.join(other) directly.

public entry fun join<T>(self: &mut sui::coin::Coin<T>, coin: sui::coin::Coin<T>)

Function join_vec

Join everything in coins with self

public entry fun join_vec<T>(self: &mut sui::coin::Coin<T>, coins: vector<sui::coin::Coin<T>>)

Function join_vec_and_transfer

Join a vector of Coin into a single object and transfer it to receiver.

public entry fun join_vec_and_transfer<T>(coins: vector<sui::coin::Coin<T>>, receiver: address)