getrawtransaction
Returns a transaction by ID. This method uses 80 credits from your daily balance.
Pass blockhash to look up a confirmed transaction in a specific block.
Without blockhash, the method searches the mempool and the transaction index.
Parameters
txid: (string) [required] - Transaction ID.verbosity: (integer) [optional] - Level of detail in the response. The default is0.0- Returns the serialized transaction as a hex-encoded string.1- Returns a decoded transaction object.2- Same as1, and includesfeeand each input'sprevoutwhen undo data is available.
blockhash: (string) [optional] - Hash of the block that contains the transaction.
Returns
result: (string or object) - The hex-encoded transaction when verbosity is 0. Otherwise, a transaction object:
in_active_chain: (boolean) [optional] -truewhen the block is on the main chain. Present only when you passblockhash.txid: (string) - Transaction ID.hash: (string) - Witness transaction ID (wtxid). Equal totxidwhen there's no witness data.version: (integer) - Transaction version.size: (integer) - Serialized size, in bytes.vsize: (integer) - Virtual size, in vbytes.weight: (integer) - Transaction weight, as defined in BIP 141.locktime: (integer) - Lock time.vin: (array) - Inputs. Each input contains:txid: (string) - ID of the transaction whose output is spent. Absent for coinbase inputs.vout: (integer) - Index of the spent output. Absent for coinbase inputs.scriptSig: (object) - Unlocking script, withasmandhexfields. Absent for coinbase inputs.coinbase: (string) - Coinbase data, as a hex string. Present only for coinbase inputs.txinwitness: (array) [optional] - Witness stack items, as hex strings.sequence: (integer) - Sequence number.
vout: (array) - Outputs. Each output contains:value: (number) - Amount, in BTC.n: (integer) - Output index.scriptPubKey: (object) - Locking script:asm: (string) - Disassembled script.desc: (string) - Inferred output descriptor.hex: (string) - Script, as a hex string.address: (string) [optional] - Bitcoin address, when the script type has one.type: (string) - Script type, such aspubkey,pubkeyhash,scripthash,witness_v0_keyhash,witness_v0_scripthash,witness_v1_taproot, ornulldata.
hex: (string) - Serialized transaction, as a hex-encoded string.blockhash: (string) [optional] - Hash of the block that contains the transaction. Absent for mempool transactions.confirmations: (integer) [optional] - Number of confirmations. Absent for mempool transactions.blocktime: (integer) [optional] - Timestamp of the block that contains the transaction, in Unix epoch seconds.time: (integer) [optional] - Same asblocktime.
Request
- curl
curl https://bitcoin-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", 1, "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"]}'
Response
- JSON
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"in_active_chain": true,
"txid": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"hash": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
"version": 1,
"size": 134,
"vsize": 134,
"weight": 536,
"locktime": 0,
"vin": [
{
"coinbase": "04ffff001d0104",
"sequence": 4294967295
}
],
"vout": [
{
"value": 50.00000000,
"n": 0,
"scriptPubKey": {
"asm": "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG",
"desc": "pk(0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee)#qnv32gt7",
"hex": "410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac",
"type": "pubkey"
}
}
],
"hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000",
"blockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"confirmations": 971402,
"time": 1231469665,
"blocktime": 1231469665
}
}