These docs are for v0.16.0. Click to read the latest docs for v19.0.0-redirect.

Simple Raw Transaction

The raw transaction RPCs allow users to create custom transactions and delay broadcasting those transactions. However, mistakes made in raw transactions may not be detected by Dash Core, and a number of raw transaction users have permanently lost large numbers of duffs, so please be careful using raw transactions on mainnet.

This subsection covers one of the simplest possible raw transactions.


Note: the following steps pick up where the Simple Spending Tutorial left off

1. List unspent outputs

Re-rerun listunspent. We now have three UTXOs: the two transactions we created before plus the coinbase transaction from block #2. We save the TXID and output index number (vout) of that coinbase UTXO to shell variables.

dash-cli -regtest listunspent
    "txid": "f84ca4ad33ec7889d3c6ac670152137a3ee1603c4096230a10562976f700d130",
    "vout": 0,
    "address": "yRdk89fwSW1mUBxQo5fCmEfTva7b4wh2H5",
    "account": "",
    "scriptPubKey": "76a9143a4e8960f26c1fa82d937046959b656e4dd7966688ac",
    "amount": 10.00000000,
    "confirmations": 1,
    "ps_rounds": -2,
    "spendable": true,
    "solvable": true
    "txid": "f84ca4ad33ec7889d3c6ac670152137a3ee1603c4096230a10562976f700d130",
    "vout": 1,
    "address": "yavnyFMebbfX4F2VC25P18FW6LS66h2wqJ",
    "scriptPubKey": "76a914a0411dbed3eab4341d5c41496d61b4fa1b22037e88ac",
    "amount": 490.00000000,
    "confirmations": 1,
    "ps_rounds": -2,
    "spendable": true,
    "solvable": true
    "txid": "9036265a8f577421e556cd4f729752d73469953deea759de11efa9ba354936a8",
    "vout": 0,
    "address": "yWtgzKSckhedxtJ8NXhShWGjfBivkvBGgG",
    "scriptPubKey": "21023fff9c9dc9088c0aeba90d75413705091111311d761054de23ac\
    "amount": 500.00000000,
    "confirmations": 101,
    "ps_rounds": -2,
    "spendable": true,
    "solvable": true

> UTXO_TXID=9036265a8f577421e556cd4f729752d73469953deea759de11ef[...]

2. Get new address

dash-cli -regtest getnewaddress

> NEW_ADDRESS=yfV9Wirf5RkYHgNDttjpBz8Wdi8BavLHcP

3. Create raw transaction

Using two arguments to the createrawtransaction RPC, we create a new raw format transaction. The first argument (a JSON array) references the txid of the coinbase transaction from block #2 and the index number (0) of the output from that transaction we want to spend. The second argument (a JSON object) creates the output with the address ( public key hash) and number of DASH we want to transfer. We save the resulting raw format transaction to a shell variable.


Transaction fee warning

Warning: createrawtransaction does not automatically create change outputs, so you can easily accidentally pay a large transaction fee.

In this example, our input had 500.0000 DASH and our output ($NEW_ADDRESS) is being paid 499.9999 DASH, so the transaction will include a fee of 0.0001 DASH. If we had paid $NEW_ADDRESS only 100 DASH with no other changes to this transaction, the transaction fee would be a whopping 400 DASH. See the Complex Raw Transaction subsection below for how to create a transaction with multiple outputs so you can send the change back to yourself.

## Outputs - inputs = transaction fee, so always double-check your math!
dash-cli -regtest createrawtransaction ''' \
    [ \
      { \
        "txid": "'$UTXO_TXID'", \
        "vout": '$UTXO_VOUT' \
      } \
    ] \
    ''' ''' \
    { \
      "'$NEW_ADDRESS'": 499.9999 \

> RAW_TX=0100000001a8364935baa9ef11de59a7ee3d956934d75297724fcd5[...]

4. Decode raw transaction

Use the decoderawtransaction RPC to see exactly what the transaction we just created does.

dash-cli -regtest decoderawtransaction $RAW_TX
  "txid": "7cbd2245ee5d824c00fc08b3bf2f694ad9a215d38d897fcf2df64a43c59bb97b",
  "size": 85,
  "version": 1,
  "locktime": 0,
  "vin": [
      "txid": "9036265a8f577421e556cd4f729752d73469953deea759de11efa9ba354936a8",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      "sequence": 4294967295
  "vout": [
      "value": 499.99990000,
      "valueSat": 49999990000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 d240140859744755d73e5967081c3bedceffc5db\
                  OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914d240140859744755d73e5967081c3bedceffc5db88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [

5. Sign transaction

Use the signrawtransaction RPC to sign the transaction created by createrawtransaction and save the returned "hex" raw format signed transaction to a shell variable.

dash-cli -regtest signrawtransaction $RAW_TX
  "hex": "0100000001a8364935baa9ef11de59a7ee3d956934d75297724fcd\
  "complete": true

> SIGNED_RAW_TX=0100000001a8364935baa9ef11de59a7ee3d956934d75297[...]

Even though the transaction is now complete, the Dash Core node we're connected to doesn't know anything about the transaction, nor does any other part of the network. We've created a spend, but we haven't actually spent anything because we could simply unset the $SIGNED_RAW_TX variable to eliminate the transaction.

6. Send raw transaction

Send the signed transaction to the connected node using the sendrawtransaction RPC. After accepting the transaction, the node would usually then broadcast it to other peers, but we're not currently connected to other peers because we started in regression test mode.

dash-cli -regtest sendrawtransaction $SIGNED_RAW_TX

7. Mine a block

Generate a block to confirm the transaction and then clear our shell variables.

dash-cli -regtest generate 1


Whatโ€™s Next