For the complete documentation index, see llms.txt. This page is also available as Markdown.

getrawtransaction - Bitcoin Cash

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

This method returns the raw transaction data for a transaction id. With verbose set to false it returns the serialized hex; with true it returns a decoded JSON object.

Parameters

Parameter
Type
Required
Description

txid

string

Yes

The transaction id

verbose

boolean

No

false for hex, true for a decoded object. Default false

blockhash

string

No

The block in which to look for the transaction

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getrawtransaction",
    "params": ["10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642", false, null],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');
const { data } = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
  jsonrpc: '2.0', method: 'getrawtransaction',
  params: ['10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642', false, null], id: 'getblock.io'
});
console.log(data.result);
example.py
import requests

response = requests.post(
    'https://go.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getrawtransaction',
        'params': ["10b54fd708ab2e5703979b4ba27ca0339882abc2062e77fbe51e625203a49642", false, null],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

Response

{
    "error": null,
    "id": "getblock.io",
    "result": "01000000000101e17e03d21d051aa2bd9d336c3ac0693cfa92ce71592ceec521b1c48019ff77a101000000171600146d76e574b5f4825fe740ba6c41aaf1b319dfb80cffffffff02819a010000000000160014422002d927a1cae901eac668444cce8dd0ae60d529b31b0b0000000017a914f5b48d1130dc3d366d1eabf6783a552d1c8e08f487000000000"
}

Response Parameters

Parameter
Type
Description

error

null|object

Error object when the call fails, otherwise null

id

string

Request identifier matching the request

result

string|object

Serialized transaction hex, or a decoded object when verbose is true

Use Cases

  • Transaction Decoding: Retrieve and inspect a confirmed transaction's inputs and outputs

  • Receipt Rendering: Display transaction detail in a wallet or explorer

  • Proof Construction: Fetch raw hex needed to build or verify a transaction proof

  • Rebroadcast: Retrieve raw hex to resubmit a dropped transaction

Error Handling

Error Code
Message
Description

-8

Invalid parameter

txid is not a valid 64-character hex string

-5

Transaction not found

No transaction with the given id is available; a txindex may be required

-32603

Internal error

Node failed to read the transaction

Was this helpful?