check_tx - Cosmos

Runs a CheckTx against the application for a transaction without broadcasting it, returning the validation result.

Method

check_tx

Parameters

ParameterTypeDescription
txstringBase64-encoded signed transaction

Example

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

# JSON-RPC over HTTP (POST)
curl -X POST "${COSMOS_TM}" -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": "getblock.io", "method": "check_tx", "params": {"tx": "Cg8KQ..."}}'

# URI over HTTP (GET)
curl "${COSMOS_TM}check_tx?tx=Cg8KQ..."

Response

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

Response Fields

FieldTypeDescription
codenumberValidation result code (0 = valid)
gas_wantedstringDeclared gas limit
gas_usedstringGas used by CheckTx

Use Cases

  • Dry run: Validate a transaction before broadcasting

Error Handling

ErrorMessageDescription
-32600 / Invalid requestInvalid requestThe JSON-RPC envelope was malformed
-32602 / Invalid paramsInvalid paramsA parameter was missing or of the wrong type
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect