# sui_dryRunTransactionBlock{deprecated} - Sui

> Example code for the sui_dryRunTransactionBlock JSON-RPC method. Complete guide on how to use sui_dryRunTransactionBlock JSON-RPC in GetBlock Web3 documentation.

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.

> **Warning:** This method is deprecated

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| tx_bytes | Base64 | Yes | BCS serialized transaction data bytes |

## Returns

| Field | Type | Description |
| --- | --- | --- |
| effects | object | Simulated execution effects |
| events | array | Events that would be emitted |
| objectChanges | array | Objects that would be modified |
| balanceChanges | array | Balance changes that would occur |
| input | object | Parsed transaction input |

## Request Example

#### cURL

#### curl

```bash
curl -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>"]
}'
```

#### JavaScript (Axios)

#### request.js

```javascript
const 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));
```

#### Python

#### request.py

```python
import 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())
```

#### Rust

#### main.rs

```rust
use 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

| Parameter | Type | Description |
| --- | --- | --- |
| effects | object | Simulated transaction effects and gas usage |
| events | array | Events that would be emitted |
| objectChanges | array | Objects that would be created/modified/deleted |
| balanceChanges | array | Balance changes for each affected address |
| input | object | Parsed 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 Code | Description |
| --- | --- |
| -32602 | Invalid params - malformed transaction bytes |
| -32603 | Internal error - simulation failed |
| MoveAbort | Move execution aborted with error code |
| InsufficientGas | Gas budget would be insufficient |

## SDK Integration

#### Sui TypeScript SDK

#### example.ts

```typescript
import { 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);
```

#### Sui Rust SDK

#### main.rs

```rust
use 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(())
}
```
