sui_executeTransactionBlock
Executes a signed transaction block on the Sui network, enabling coin transfers, smart contract interactions, and object manipulations.
Overview​
The sui_executeTransactionBlock
method is the primary way to submit transactions to the Sui blockchain. It processes pre-signed transaction blocks that can contain multiple commands, such as transferring objects, calling Move functions, splitting coins, and more. The method supports various response options to retrieve transaction effects, events, and object changes.
Parameters​
Parameter | Type | Required | Description |
---|---|---|---|
transactionBlockBytes | string | Yes | BCS serialized transaction data as base64 string |
signature | array | Yes | Array of signatures (base64) from transaction signers |
options | object | No | Options controlling response content |
requestType | string | No | Execution type: "WaitForEffectsCert" (default) or "WaitForLocalExecution" |
Options Object​
Field | Type | Default | Description |
---|---|---|---|
showInput | boolean | false | Include transaction input in response |
showRawInput | boolean | false | Include raw transaction input |
showEffects | boolean | false | Include transaction effects |
showEvents | boolean | false | Include emitted events |
showObjectChanges | boolean | false | Include object modifications |
showBalanceChanges | boolean | false | Include balance changes |
showRawEffects | boolean | false | Include raw effects data |
Request Types​
- WaitForEffectsCert: Waits for transaction to be checkpointed (recommended)
- WaitForLocalExecution: Returns after local execution (faster but less reliable)
Returns​
Returns transaction execution results based on requested options.
Field | Type | Description |
---|---|---|
digest | string | Transaction digest (unique identifier) |
transaction | object | Transaction input (if requested) |
rawTransaction | string | Raw transaction bytes (if requested) |
effects | object | Transaction effects including status and changes |
events | array | Events emitted during execution |
objectChanges | array | Objects created, modified, or deleted |
balanceChanges | array | Coin balance modifications |
timestampMs | string | Execution timestamp in milliseconds |
checkpoint | string | Checkpoint sequence number |
Code Examples​
- cURL
- JavaScript
- Python
curl -X POST https://sui-mainnet.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "sui_executeTransactionBlock",
"params": [
"AAACAAgAypo7AAAAAAAg7Vgw...transaction_bytes_base64...",
[
"AGnKiH1Z0bj...signature_base64..."
],
{
"showEffects": true,
"showEvents": true,
"showObjectChanges": true,
"showBalanceChanges": true
},
"WaitForEffectsCert"
],
"id": 1
}'
// Using Sui SDK to build and execute transaction
import { TransactionBlock } from '@mysten/sui.js/transactions';
import { SuiClient } from '@mysten/sui.js/client';
import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
const client = new SuiClient({
url: 'https://sui-mainnet.dwellir.com/YOUR_API_KEY'
});
// Build transaction
const tx = new TransactionBlock();
tx.transferObjects(
[tx.object('0x...')],
tx.pure('0xrecipient_address')
);
// Sign and execute
const keypair = Ed25519Keypair.fromSecretKey(secretKey);
const result = await client.signAndExecuteTransactionBlock({
signer: keypair,
transactionBlock: tx,
options: {
showEffects: true,
showEvents: true,
showObjectChanges: true,
showBalanceChanges: true
}
});
console.log('Transaction digest:', result.digest);
console.log('Status:', result.effects?.status);
console.log('Gas used:', result.effects?.gasUsed);
import requests
import json
from pysui import SuiClient, SuiConfig
from pysui.sui.sui_txn import SuiTransaction
# Initialize client
client = SuiClient(SuiConfig.default(
rpc_url="https://sui-mainnet.dwellir.com/YOUR_API_KEY"
))
# Build transaction (example: transfer SUI)
txn = SuiTransaction(client)
txn.transfer_sui(
recipient="0xrecipient_address",
amount=1000000000, # 1 SUI in MIST
from_address="0xsender_address"
)
# Sign and execute
result = txn.execute(
gas_budget=10000000,
options={
"showEffects": True,
"showEvents": True,
"showObjectChanges": True
}
)
print(f"Transaction digest: {result['digest']}")
print(f"Status: {result['effects']['status']['status']}")
print(f"Gas cost: {result['effects']['gasUsed']['computationCost']}")
Response Example​
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"digest": "HkCBSKmKKPqPR5hiKnp7j2JYN6HDkEZSjGpLvNapKwhF",
"effects": {
"messageVersion": "v1",
"status": {
"status": "success"
},
"executedEpoch": "251",
"gasUsed": {
"computationCost": "1000000",
"storageCost": "2588000",
"storageRebate": "978120",
"nonRefundableStorageFee": "9880"
},
"modifiedAtVersions": [
{
"objectId": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
"sequenceNumber": "31823925"
}
],
"transactionDigest": "HkCBSKmKKPqPR5hiKnp7j2JYN6HDkEZSjGpLvNapKwhF",
"created": [],
"mutated": [
{
"owner": {
"AddressOwner": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f"
},
"reference": {
"objectId": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
"version": 31823925,
"digest": "2VivvnKSj89drLLNdkKhDxPFXTzPFkVH4V4DpCwN6pJk"
}
}
],
"deleted": [],
"dependencies": [
"5yxPx9j5yQVhR3NmM9vHkvPq98zng3kFgPvL5pb6MfmT"
]
},
"events": [
{
"id": {
"txDigest": "HkCBSKmKKPqPR5hiKnp7j2JYN6HDkEZSjGpLvNapKwhF",
"eventSeq": "0"
},
"packageId": "0x3",
"transactionModule": "sui_system",
"sender": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f",
"type": "0x3::validator::StakingRequestEvent",
"parsedJson": {
"amount": "100000000000",
"epoch": "251",
"staker_address": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f",
"validator_address": "0x..."
}
}
],
"objectChanges": [
{
"type": "mutated",
"sender": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f",
"owner": {
"AddressOwner": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f"
},
"objectType": "0x2::coin::Coin<0x2::sui::SUI>",
"objectId": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
"version": "31823925",
"previousVersion": "31823924",
"digest": "2VivvnKSj89drLLNdkKhDxPFXTzPFkVH4V4DpCwN6pJk"
}
],
"balanceChanges": [
{
"owner": {
"AddressOwner": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f"
},
"coinType": "0x2::sui::SUI",
"amount": "-2609880"
}
],
"timestampMs": "1703012345678",
"checkpoint": "19823924"
}
}
Transaction Building Examples​
Transfer SUI Coins​
const tx = new TransactionBlock();
// Transfer SUI to recipient
const [coin] = tx.splitCoins(tx.gas, [tx.pure(1000000000)]); // 1 SUI
tx.transferObjects([coin], tx.pure(recipientAddress));
const result = await client.signAndExecuteTransactionBlock({
signer: keypair,
transactionBlock: tx,
});
Call Move Function​
const tx = new TransactionBlock();
// Call a Move function
tx.moveCall({
target: '0xpackage::module::function',
arguments: [
tx.pure('string_argument'),
tx.pure(123, 'u64'),
tx.object('0xobject_id')
],
typeArguments: ['0x2::sui::SUI']
});
const result = await client.signAndExecuteTransactionBlock({
signer: keypair,
transactionBlock: tx,
});
Complex Transaction with Multiple Commands​
const tx = new TransactionBlock();
// Split coins
const [coin1, coin2] = tx.splitCoins(tx.gas, [
tx.pure(1000000000),
tx.pure(2000000000)
]);
// Transfer first coin
tx.transferObjects([coin1], tx.pure(recipient1));
// Use second coin in Move call
tx.moveCall({
target: '0xpackage::defi::deposit',
arguments: [coin2]
});
// Merge remaining coins
tx.mergeCoins(tx.gas, [/* other coins */]);
const result = await client.signAndExecuteTransactionBlock({
signer: keypair,
transactionBlock: tx,
options: {
showEffects: true,
showEvents: true,
showObjectChanges: true
}
});
Transaction Effects Status​
Understanding transaction status from effects:
Success Status​
if (result.effects.status.status === 'success') {
console.log('Transaction successful');
// Process created/modified objects
result.effects.created?.forEach(obj => {
console.log('Created object:', obj.reference.objectId);
});
}
Failure Handling​
if (result.effects.status.status === 'failure') {
console.error('Transaction failed:', result.effects.status.error);
// Common errors:
// - InsufficientGas: Increase gas budget
// - ObjectNotFound: Object doesn't exist
// - InvalidInput: Check function arguments
}
Gas Management​
Setting Gas Budget​
const tx = new TransactionBlock();
tx.setGasBudget(10000000); // 0.01 SUI
Estimating Gas Costs​
// Use dryRunTransactionBlock first to estimate
const dryRun = await client.dryRunTransactionBlock({
transactionBlock: await tx.build({ client })
});
const estimatedGas =
Number(dryRun.effects.gasUsed.computationCost) +
Number(dryRun.effects.gasUsed.storageCost) -
Number(dryRun.effects.gasUsed.storageRebate);
console.log('Estimated gas:', estimatedGas);
Best Practices​
1. Always Handle Transaction Status​
const executeTransaction = async (tx) => {
try {
const result = await client.signAndExecuteTransactionBlock({
signer: keypair,
transactionBlock: tx,
options: { showEffects: true }
});
if (result.effects?.status?.status !== 'success') {
throw new Error(`Transaction failed: ${result.effects.status.error}`);
}
return result;
} catch (error) {
console.error('Execution error:', error);
throw error;
}
};
2. Use Appropriate Request Type​
- Use
WaitForEffectsCert
for critical transactions requiring confirmation - Use
WaitForLocalExecution
for faster response when immediate confirmation isn't critical
3. Monitor Gas Usage​
const gasUsed = result.effects.gasUsed;
console.log(`
Computation: ${gasUsed.computationCost}
Storage: ${gasUsed.storageCost}
Rebate: ${gasUsed.storageRebate}
Total: ${
Number(gasUsed.computationCost) +
Number(gasUsed.storageCost) -
Number(gasUsed.storageRebate)
}
`);
Related Methods​
- sui_getObject - Retrieve object information
- suix_getBalance - Query coin balances
Common Errors​
Error | Description | Solution |
---|---|---|
InsufficientGas | Gas budget too low | Increase gas budget |
ObjectNotFound | Referenced object doesn't exist | Verify object IDs |
InvalidInput | Incorrect function arguments | Check argument types and values |
ObjectVersionMismatch | Object was modified | Refresh object version |
InvalidSignature | Signature verification failed | Ensure correct keypair |
Need help? Contact our support team or check the Sui documentation.