sui_dryRunTransactionBlock{deprecated} - Sui

This method performs a dry run of a transaction block without committing it to the blockchain. This simulates transaction execution to predict effects, gas costs, and potential errors before actual submission. It's essential for transaction validation, gas estimation, and debugging.

This method is deprecated

Parameters

ParameterTypeRequiredDescription
tx_bytesBase64YesBCS serialized transaction data bytes

Returns

FieldTypeDescription
effectsobjectSimulated execution effects
eventsarrayEvents that would be emitted
objectChangesarrayObjects that would be modified
balanceChangesarrayBalance changes that would occur
inputobjectParsed transaction input

Request Example

curl

bashcurl -X POST https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "sui_dryRunTransactionBlock",
  "params": ["AAACACB...<base64_tx_bytes>"]
}'

request.js

javascriptconst axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
  jsonrpc: '2.0',
  id: 'getblock.io',
  method: 'sui_dryRunTransactionBlock',
  params: ['AAACACB...<base64_tx_bytes>']
};

axios.post(url, payload, {
  headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

request.py

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = {
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "sui_dryRunTransactionBlock",
    "params": ["AAACACB...<base64_tx_bytes>"]
}

response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())

main.rs

rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "id": "getblock.io",
        "method": "sui_dryRunTransactionBlock",
        "params": ["AAACACB...<base64_tx_bytes>"]
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("{:#?}", result);
    
    Ok(())
}

Response Example

response.json

json{
  "jsonrpc": "2.0",
  "result": {
    "effects": {
      "messageVersion": "v1",
      "status": {
        "status": "success"
      },
      "gasUsed": {
        "computationCost": "1000000",
        "storageCost": "2000000",
        "storageRebate": "500000",
        "nonRefundableStorageFee": "0"
      }
    },
    "events": [],
    "objectChanges": [],
    "balanceChanges": [],
    "input": {}
  },
  "id": "getblock.io"
}

Response Parameters

ParameterTypeDescription
effectsobjectSimulated transaction effects and gas usage
eventsarrayEvents that would be emitted
objectChangesarrayObjects that would be created/modified/deleted
balanceChangesarrayBalance changes for each affected address
inputobjectParsed transaction input data

Use Cases

  • Estimate gas costs before submission
  • Validate transaction parameters
  • Debug failed transaction logic
  • Preview object and balance changes
  • Test smart contract interactions safely

Error Handling

Error CodeDescription
-32602Invalid params - malformed transaction bytes
-32603Internal error - simulation failed
MoveAbortMove execution aborted with error code
InsufficientGasGas budget would be insufficient

SDK Integration

example.ts

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

const client = new SuiClient({ url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' });

const tx = new Transaction();
// ... build transaction

const dryRunResult = await client.dryRunTransactionBlock({
  transactionBlock: await tx.build({ client }),
});

console.log(dryRunResult);

main.rs

rustuse sui_sdk::SuiClientBuilder;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let sui = SuiClientBuilder::default()
        .build("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .await?;
    
    // let tx_bytes = ...
    let result = sui.read_api().dry_run_transaction_block(tx_bytes).await?;
    
    println!("{:?}", result);
    Ok(())
}