Post
Topic
Board Bitcoin Technical Support
Merits 3 from 2 users
Re: Using the Data field in OP_RETURN transactions, and converting text to hex
by
HCP
on 08/01/2021, 03:47:23 UTC
⭐ Merited by ETFbitcoin (2) ,FractalEncrypt (1)
When I create the raw transaction, my node is giving me an error about the data I want to include.

For example, I tried to convert "I am FractalEncrypt" to hex and I get this:
4920616d204672616374616c456e6372797074

When I try to insert this string into the data field below I get
Error: Error parsing JSON:

createrawtransaction \
'[{"txid": "txid1", "vout": vout1},
{"txid": "txid2", "vout": vout2}]' \
'{"address1": Amount1,
"address2": Amount2,
"address3": Amount3,
"data": 4920616d204672616374616c456e6372797074}'

Maybe try wrapping your "data" in " "'s? Huh

I just used this on the Bitcoin Core console:
Code:
createrawtransaction '[{"txid": "TXID", "vout": 0}]' '{"Address1": Amount1, "data": "4920616d204672616374616c456e6372797074"}'

And it immediately created the rawtransaction, which includes the following when I decoderawtransaction:
Code:
...
{
      "value": 0.00000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_RETURN 4920616d204672616374616c456e6372797074",
        "hex": "6a134920616d204672616374616c456e6372797074",
        "type": "nulldata"
}
...