Skip to main content

Transactions


Facts

Fact Sheet

How to transfer an object

CLI
# Transfer an object
sui client transfer --to <ADDRESS> --object-id <OBJECT_ID> --gas-budget <GAS_BUDGET>

How to transfer Sui

CLI
# Transfer SUI, and pay gas with the same SUI coin object.
# If amount is specified, only the amount is transferred;
# otherwise the entire object is transferred

sui client transfer-sui --to <ADDRESS> --sui-coin-object-id <SUI_COIN_OBJECT_ID> --gas-budget <GAS_BUDGET>

How to merge coins

CLI
# Merge two coin objects into one coin
sui client merge-coin --primary-coin <PRIMARY_COIN> --coin-to-merge <COIN_TO_MERGE> --gas-budget <GAS_BUDGET>

How to split coins

Split a coin object into multiple coins.

CLI
sui client split-coin --coin-id <COIN_ID> --gas-budget <GAS_BUDGET> --amounts <AMOUNTS>

How to publish a package

CLI
sui client publish --gas-budget <GAS_BUDGET> --path <PACKAGE_PATH>

How to make a Move call

You can make a move call only if you provide a package, module and a function.
The standardized rule of a move call is : package::module::function.

CLI
sui client call --function function --module module --package <PACKAGE_ID> --gas-budget <GAS_BUDGET>

Transaction Options

Sui RPC API allows you to specify options to control the results returned when
executing a transaction. The following key values are the available options:

{
  "showBalanceChanges": true,
  "showEffects": true,
  "showEvents": true,
  "showInput": true,
  "showObjectChanges": true,
  "showRawInput": true
}

Using the above in your transaction execution calls would return all information about the transaction.
However; you can choose individual flags individually or in combination.

Python
from pysui.sui.sui_clients.sync_client import SuiClient
from pysui.sui.sui_config import SuiConfig
from pysui.sui.sui_txn.sync_transaction import SuiTransaction
from pysui.sui.sui_clients.common import handle_result
from pysui.sui.sui_builders.get_builders import GetTx

def get_txn_with_options(client: SuiClient, target_digest: str):
    """Iterate through various options to display associated results."""
    options = {
        "showEffects": True,
        "showEvents": True,
        "showBalanceChanges": True,
        "showObjectChanges": True,
        "showRawInput": True,
        "showInput": True,
    }
    # For each options
    entries = [dict([x]) for x in options.items()]
    for entry in entries:
        print(handle_result(client.execute(GetTx(digest=target_digest, options=entry))).to_json(indent=2))

    # Uncomment for full options (defaults to ALL the above)
    # print(handle_result(client.execute(GetTx(digest=target_digest))).to_json(indent=2))

def execution_options(client: SuiClient = None):
    """Setup transaction and inspect options."""
    client = client if client else SuiClient(SuiConfig.default_config())
    # Create simple transaction
    txer = SuiTransaction(client)
    scres = txer.split_coin(coin=txer.gas, amounts=[100000000])
    txer.transfer_objects(transfers=[scres], recipient=client.config.active_address)
    # Execute
    tx_result = txer.execute(gas_budget="100000")
    # Review result
    if tx_result.is_ok():
        get_txn_with_options(client, tx_result.result_data.digest)
    else:
        print(tx_result.result_string)