check_tx - Akash

Runs CheckTx against a transaction (validating it against the mempool rules) and returns the result, without adding it to the mempool.

The transaction below is a placeholder and cannot be broadcast as written. Sent unchanged it returns -32602 Invalid params with an illegal base64 message. Substitute a real signed, protobuf-encoded transaction, base64-encoded. The response shown is the shape returned on acceptance.

Parameters

ParameterTypeRequiredDescription
txstringYesBase64 transaction bytes

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "check_tx",
    "params": {"tx": "Cr0BC..."}
}'

example.js

javascriptconst axios = require('axios');
const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', { jsonrpc: '2.0', id: 'getblock.io', method: 'check_tx', params: {"tx": "Cr0BC..."} }, { headers: { 'Content-Type': 'application/json' } });
console.log(response.data.result);

example.py

pythonimport requests
response = requests.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', headers={'Content-Type': 'application/json'}, json={'jsonrpc': '2.0', 'id': 'getblock.io', 'method': 'check_tx', 'params': {"tx": "Cr0BC..."}})
print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    let res = client.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/").json(&json!({"jsonrpc":"2.0","id":"getblock.io","method":"check_tx","params":{"tx": "Cr0BC..."}})).send().await?.json::<Value>().await?;
    println!("{}", res["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "code": 0,
        "gas_wanted": "200000",
        "gas_used": "118000",
        "log": "[]"
    }
}

Response Fields

FieldTypeDescription
codeintegerCheckTx code; 0 = valid
gas_usedstringGas used during the check
logstringLog on failure

Use Cases

  • Pre-validation: Test a transaction before broadcasting
  • Fee Sizing: Read gas_used to size fees

Error Handling

ErrorMessageDescription
-32603 / Internal errorInternal errorUndecodable transaction
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect