blockchaintransactionbroadcast

Rostrum Electrum for Bitcoin Cash

Overview

The blockchain.transaction.broadcast method allows clients to broadcast a raw transaction to the network. This function is essential for applications that need to send transactions directly.

Parameters

NameTypeRequiredDescription
raw_txstringYesThe raw transaction as a hexadecimal string.

Returns

The method returns the transaction hash if the transaction is successfully broadcast to the network. In case of an error, the method returns a JSON RPC error in newer protocol versions or an error message directly in the result for protocol version 1.0.

FieldDescription
txidThe transaction hash as a hexadecimal string, or an error message (protocol v1.0).

Example Result

"a76242fce5753b4212f903ff33ac6fe66f2780f34bdb4b33b175a7815a11a98e"

Protocol version 1.0 error example:

"258: txn-mempool-conflict"

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/rostrum-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
    "method": "blockchain.transaction.broadcast",
    "params": ["0100000001abcdef..."],
    "id": 1,
    "jsonrpc": "2.0"
}'
// yarn add @tatumio/tatum

import { TatumSDK, Rostrum, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Rostrum>({ network: Network.ROSTRUM })

const transactionHash = await tatum.rpc.broadcastTransaction('0100000001abcdef...')

console.log('Transaction Hash:', transactionHash)

await rostrum.destroy() // Destroy Tatum SDK - needed for stopping background jobs when done