Guides / Broadcast a raw transaction

Broadcast a raw transaction

A raw transaction is the signed bytes the network relays. Testnet is a good place to build one, decode it, and push it yourself, with nothing at stake.

On this page

What a raw transaction is

A raw transaction is a complete, signed transaction serialized to hexadecimal: the exact bytes a node relays across the network. The lifecycle is always the same three steps:

  1. Build: choose which UTXOs to spend and where the outputs go.
  2. Sign: prove you own the inputs.
  3. Broadcast: hand the signed hex to the network.

Before broadcasting, you can inspect what you built with decoderawtransaction to double-check the inputs, outputs, and fee.

Three ways to broadcast

1. Let a wallet do it (easiest)

TestnetWallet builds, signs, and broadcasts for you. For most people this is all you ever need.

2. Paste the hex into an explorer

Many explorers have a "broadcast" or "push transaction" tool. Paste your signed hex into TestnetScan and it relays it for you. That's handy when you signed a transaction offline.

3. Send it from a node over RPC

If you run your own node, use the sendrawtransaction RPC:

# Bitcoin testnet4
bitcoin-cli -testnet4 sendrawtransaction <signed-hex>

# Litecoin testnet
litecoin-cli -testnet sendrawtransaction <signed-hex>

# Inspect before sending
bitcoin-cli -testnet4 decoderawtransaction <signed-hex>

Keep your node's RPC interface private when you do this.

Common errors

ErrorWhat it means
Below min relay feeYour fee is too low for nodes to relay it. Rebuild with a higher fee.
Missing / already-spent inputsA UTXO you referenced doesn't exist or was already spent. Refresh your UTXO set.
Non-standard / dustAn output or script the network won't relay (e.g. an amount below the dust threshold).

After it's sent

Watch it move from the mempool into a block on TestnetScan, and count its confirmations. If it never gets mined, see debugging a stuck transaction.

Write a message (OP_RETURN)

A transaction can also carry a short note instead of just moving coins. An OP_RETURN output carries a small amount of arbitrary data (about 80 bytes on most nodes, more on newer ones) and is provably unspendable, so it records your message on the chain without bloating the set of spendable coins. People use it for timestamps, proofs that something existed at a given time, and protocol metadata.

On testnet it costs nothing to try: write a few words onto a real blockchain, then read them back on the explorer. The companion code examples include a recipe that does exactly this.

It is public and permanent

Anything in an OP_RETURN is visible to everyone and cannot be deleted. Never write anything private, on testnet or anywhere.

Testnet coins are fake money

  • They have no market value, so never buy or sell them.
  • Never use a real seed phrase or import a real wallet on testnet.
  • Never send mainnet BTC, LTC, or XMR to a testnet address.