Skip to main content
Sui’s programmable transaction blocks allow you to chain multiple operations in a single transaction.

Basic Transaction Structure

A transaction contains:
  • Inputs: Arguments passed to the transaction
  • Commands: Operations to perform (Move calls, transfers, etc.)
  • Gas payment: Coins used to pay for execution

Simple Transfer

import { Transaction } from '@mysten/sui/transactions';

const tx = new Transaction();

// Transfer 1 SUI (1_000_000_000 MIST)
tx.transferObjects(
  [tx.splitCoins(tx.gas, [1_000_000_000])],
  '0x...recipient...'
);

tx.setSender(senderAddress);

Programmable Transaction Blocks

Split and transfer coins

const tx = new Transaction();

// Split multiple amounts
const [coin1, coin2, coin3] = tx.splitCoins(tx.gas, [
  1000000, // 0.001 SUI
  2000000, // 0.002 SUI
  3000000, // 0.003 SUI
]);

// Transfer to different recipients
tx.transferObjects([coin1], recipient1);
tx.transferObjects([coin2], recipient2);
tx.transferObjects([coin3], recipient3);

Call Move functions

const tx = new Transaction();

// Call a Move function
tx.moveCall({
  target: '0xPACKAGE::module::function_name',
  arguments: [
    tx.pure.u64(42),
    tx.pure.address('0x...'),
    tx.object('0xOBJECT_ID'),
  ],
  typeArguments: ['0x2::sui::SUI'],
});

Common Patterns

Merge coins

const tx = new Transaction();

// Merge multiple coins into one
tx.mergeCoins(coinId1, [coinId2, coinId3, coinId4]);

Create and transfer object

const tx = new Transaction();

// Call function that creates object
const [newObject] = tx.moveCall({
  target: '0xPACKAGE::nft::mint',
  arguments: [
    tx.pure.string('NFT Name'),
    tx.pure.string('Description'),
  ],
});

// Transfer the created object
tx.transferObjects([newObject], recipient);

Complex multi-step transaction

const tx = new Transaction();

// 1. Split coins
const [paymentCoin] = tx.splitCoins(tx.gas, [1000000]);

// 2. Purchase item
const [item] = tx.moveCall({
  target: '${packageId}::shop::purchase',
  arguments: [tx.object(shopId), paymentCoin],
});

// 3. Customize item
tx.moveCall({
  target: '${packageId}::item::customize',
  arguments: [
    item,
    tx.pure.string('Custom Name'),
  ],
});

// 4. Transfer to owner
tx.transferObjects([item], recipient);

Gas Management

Set gas budget

const tx = new Transaction();
tx.setGasBudget(10_000_000); // 0.01 SUI

Use specific gas coins

const tx = new Transaction();
tx.setGasPayment([{
  objectId: '0x...', 
  version: '123',
  digest: '...',
}]);

Next Steps

Build docs developers (and LLMs) love