⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

sui_dryRunTransactionBlock

Simulates transaction execution without committing to the blockchain, providing detailed effects and gas estimates.

Overview

The sui_dryRunTransactionBlock method allows you to simulate transaction execution to preview effects, estimate gas costs, and validate transaction logic before submission. This is essential for testing complex transactions, estimating costs, and ensuring transactions will succeed before spending gas.

Parameters

ParameterTypeRequiredDescription
transactionBlockBytesstringYesBCS serialized transaction data as base64 string

Returns

Returns simulated transaction effects and execution results.

FieldTypeDescription
effectsobjectSimulated transaction effects including status and changes
eventsarrayEvents that would be emitted
objectChangesarrayObjects that would be created, modified, or deleted
balanceChangesarrayBalance changes that would occur
inputobjectTransaction input data

Effects Object

FieldTypeDescription
statusobjectExecution status (success/failure)
executedEpochstringEpoch when simulated
gasUsedobjectGas cost breakdown
modifiedAtVersionsarrayObjects and their versions
createdarrayObjects that would be created
mutatedarrayObjects that would be modified
deletedarrayObjects that would be deleted
dependenciesarrayTransaction dependencies

Code Examples

curl -X POST https://api-sui-mainnet-full.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "sui_dryRunTransactionBlock",
"params": [
"AAAKAQCszKNyuM4wPiFvXHvlT/xuQhvaIKiHBKbbuv8gmjTIC65P7QUAAAAAIHsNXvA33dXqSF155/NKsU8LJa8mLtQ1zMCx4BU6rH3ZAAhjK1cAAAAAAAEB2qRikmMsPE2PMfI+oPmzaij/NnfpaEmA5EOEA6Z6PY8uBRgAAAAAAAABAQbYr55q/ScmLbQ28NN7MEoEH3EMPqH6TDqbqzazVprTaYodAAAAAAABAAS47AAAAAR8KAEAAAjQBwAAAAAAAAAIYytXAAAAAAAAAQEBAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAQAAAAAAAAAAAgIAAQEBAACPqrkCKOTE35HEFia7rvoZ/CXFFEBaxk3lRXjeyeb17g5wb29sX3NjcmlwdF92MihvcGVuX3Bvc2l0aW9uX3dpdGhfbGlxdWlkaXR5X2J5X2ZpeF9jb2luAgfAYABhEQFrigIK1bM4NJhKQ3qqfTx0wY4JqV1IrOqwjARjb2luBENPSU4ABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACA3N1aQNTVUkACgECAAEDAAEEAAEFAAEAAAIAAAEGAAEHAAEIAAEJAOSwXKixEKqsWkSxNAKyy1NLyD8ll2VzVLgUDzBJw4iEAmYyJrDN0EvxskLZ4lONh66ex3iy+q8FG3/IlxAjGAaOHCf+DwAAAAAgXCNjzpkUPSVf+9NSOPwILRtXoqiYJhKB1LQ5zDsanlOeY1q4umFhTuQ9WAG4Cn4Ze5oD8d5GEuCaXfDDD5E0POMn/g8AAAAAILqY2aH0K+yeWENsU0uNSttg4P9IZDSEi7V6HrpM9md05LBcqLEQqqxaRLE0ArLLU0vIPyWXZXNUuBQPMEnDiITvAgAAAAAAAPgsqgAAAAAAAA=="
],
"id": 1
}'

Response Example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"effects": {
"messageVersion": "v1",
"status": {
"status": "success"
},
"executedEpoch": "251",
"gasUsed": {
"computationCost": "1000000",
"storageCost": "2588000",
"storageRebate": "978120",
"nonRefundableStorageFee": "9880"
},
"modifiedAtVersions": [
{
"objectId": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
"sequenceNumber": "31823925"
}
],
"created": [],
"mutated": [
{
"owner": {
"AddressOwner": "0xd77955e670601c2c2e6e8637e383695c166aac0a86b741c266bdfb23c2e3369f"
},
"reference": {
"objectId": "0x5d3c87e88bc566e3f10c66e0275a366001ffa8b86142adc78c744de6afffeb34",
"version": 31823925,
"digest": "2VivvnKSj89drLLNdkKhDxPFXTzPFkVH4V4DpCwN6pJk"
}
}
],
"deleted": [],
"dependencies": [
"5yxPx9j5yQVhR3NmM9vHkvPq98zng3kFgPvL5pb6MfmT"
]
},
"events": [],
"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"
}
]
}
}

Use Cases

Gas Estimation

async function estimateGas(tx) {
const result = await client.dryRunTransactionBlock({
transactionBlock: await tx.build({ client })
});

const gasUsed = result.effects.gasUsed;
const totalGas =
Number(gasUsed.computationCost) +
Number(gasUsed.storageCost) -
Number(gasUsed.storageRebate);

// Add 10% buffer for safety
return Math.ceil(totalGas * 1.1);
}

Transaction Validation

async function validateTransaction(tx) {
const result = await client.dryRunTransactionBlock({
transactionBlock: await tx.build({ client })
});

if (result.effects.status.status !== 'success') {
throw new Error(`Transaction would fail: ${result.effects.status.error}`);
}

// Check specific conditions
const created = result.effects.created || [];
const deleted = result.effects.deleted || [];

console.log(`Transaction would create ${created.length} objects`);
console.log(`Transaction would delete ${deleted.length} objects`);

return true;
}

Complex Transaction Testing

async function testDeFiTransaction() {
const tx = new TransactionBlock();

// Complex DeFi operation
const [coin] = tx.splitCoins(tx.gas, [tx.pure(1000000000)]);

tx.moveCall({
target: '0xdefi::pool::swap',
arguments: [
coin,
tx.pure('0x2::sui::SUI'),
tx.pure('0xcustom::token::TOKEN')
]
});

// Test without executing
const result = await client.dryRunTransactionBlock({
transactionBlock: await tx.build({ client })
});

// Analyze events that would be emitted
const swapEvents = result.events.filter(e =>
e.type.includes('SwapExecuted')
);

console.log('Swap events:', swapEvents);
return result;
}

Best Practices

  1. Always dry run before execution for critical transactions
  2. Add gas buffer of 10-20% to estimates for safety
  3. Validate object versions before submission
  4. Check for expected events in simulation results
  5. Handle simulation failures gracefully

Common Errors

ErrorDescriptionSolution
InsufficientGasGas budget too lowIncrease gas budget based on estimate
ObjectNotFoundReferenced object doesn't existVerify object IDs
InvalidInputMalformed transactionCheck transaction construction
ObjectVersionMismatchObject was modifiedRefresh object references

Need help? Contact our support team or check the Sui documentation.