Bitcoin Forum
July 19, 2019, 11:12:35 AM *
News: Latest Bitcoin Core release: 0.18.0 [Torrent] (New!)
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: [WTB] Teach me to manually create an OP_RETURN tx  (Read 6038 times)
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 795
Merit: 1000



View Profile
February 07, 2014, 07:14:14 AM
 #1

I'm looking for somebody to teach me how to manually create and sign an OP_RETURN tx in Windows.

I don't care how you do it-- it can be working with me, you can just send me a step-by-step guide, or it can be a video you make -- whatever method you choose is fine as long as afterwards I can, on my own, create a tx with an OP_RETURN output that the Eligius pool would mine.

I have no idea how simple or complicated a task teaching me to do this is, so I'm asking for bids before I commit to some price.

My experience level is that I consider myself pretty computer savvy, but not a programmer.  I've written some simple scripts in autohotkey, I can read most programming languages and understand what the code is doing, I know the JSON format and have registered some domains with namecoind via the Windows cmd.exe.  I'm reasonably tech-savvy, but I'm not a programmer, and I use Windows.  I do NOT know ECC, and I don't know how to use point multiplication to get a public key from a private key-- I've been using Casascius' Bitcoin Address Utility for that type of thing.

So that's what you'd be working with.  Please post here or PM if you think this is something you could help me with and let me know what you'd charge.

Thanks guys!!

1563534755
Hero Member
*
Offline Offline

Posts: 1563534755

View Profile Personal Message (Offline)

Ignore
1563534755
Reply with quote  #2

1563534755
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1563534755
Hero Member
*
Offline Offline

Posts: 1563534755

View Profile Personal Message (Offline)

Ignore
1563534755
Reply with quote  #2

1563534755
Report to moderator
1563534755
Hero Member
*
Offline Offline

Posts: 1563534755

View Profile Personal Message (Offline)

Ignore
1563534755
Reply with quote  #2

1563534755
Report to moderator
1563534755
Hero Member
*
Offline Offline

Posts: 1563534755

View Profile Personal Message (Offline)

Ignore
1563534755
Reply with quote  #2

1563534755
Report to moderator
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
February 22, 2014, 05:14:16 PM
Last edit: July 27, 2014, 06:05:18 AM by dexX7
 #2

Okay, I'll try. I created f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b a few minutes ago and will use this as example.

Start up your Bitcoin-Qt/bitcoind v0.9 client and go Help - Debug. Enter: "getrawtransaction f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b".

You will then see the transaction as hex*:

Code:
01000000015d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8000000006b483045022100fd8c5227976363b79c6c2c72592e98148090ca26d89707f60dfaa19d5c59519f02207a34c47f2a55b9513d152520dd035fb9842d689c0c3350f4c0145e827e61604d01210391b373843e77f5ac1f05db4afb5151190e67cfee5a48f7925d71da7c5e919422ffffffff0100000000000000004e6a4c4b6f64617920697320466562203232203230313420616e642074686973206973206465785820402062697477617463682e636f2e2043686565727320616e64207374617920666c756666792100000000

This is the raw transaction with descriptions:

Code:
01000000          < Version
01                < Number of inputs
5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8  < Input transaction id
00000000          < Vout
00                < scriptSig length*
ffffffff          < Sequence number
01                < Number of outputs
0000000000000000  < Value
4e                < Push 78 byte (it's 78 hex encoded)
6a                < OP_RETURN
4c                < Push 76 byte (it's 76 hex encoded)
4974277320466562203232203230313420616e642074686973206973206465785820402062697477617463682e636f2e2043686565727320616c6c20616e64207374617920666c7566667921  < Payload with length of 76 byte
00000000          < Lock time

*I removed the actual scriptSig for this example.

You may notice that some data is flipped, for example the input transaction hash (compare: c8bb07dc4d2277ad506f16068f7cebc4cb481715332bd3d615ee3f46ab5f475d vs. 5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8).

To create an OP_RETURN transaction yourself, you may use this template:

Code:
0100000001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABB00000000ffffffff0100000000000000004e6a4cCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC00000000

Replace AA...A with the input transaction hash flipped, BB with vout, CC...C with your payload/message.

Go back to your debug console and type "decoderawtransaction XXX", whereby XXX is your modified transaction hex. If everything is fine, this should return some information about your transaction.

You may adjust the payload length by changing the 4e and 4c. Use a calculator to convert the numbers.

http://brainwallet.org/#converter has a hex to text and vice versa converter.

When you are finished, type: "signrawtransaction XXX", whereby XXX is your transaction hex. It should show a longer hex followed by "complete".

Copy that longer hash and type "sendrawtransaction YYY", whereby YYY is the signed transaction hex.

Last note: make sure you use only an input with 0.0001-ish BTC. It will all be considered as miner fee unless you add more outputs.

Hope that helps. Smiley


Edit: max length is now 40 byte, so you must adjust the length.

networthsigns
Sr. Member
****
Offline Offline

Activity: 448
Merit: 250


View Profile
February 22, 2014, 09:23:11 PM
 #3

From my point of view, this is a nice illustration, the op might honor dexX7 well with some coins.
yakuza699
Hero Member
*****
Offline Offline

Activity: 935
Merit: 1000


View Profile
February 22, 2014, 10:09:54 PM
 #4

So you basically want to double-spend(send same inputs twice)?

▄▄▄▄▄▄▄▄
▄▄▄▄▄▄
▄▄▄▄
BTC BitDice.me 
.
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
February 22, 2014, 10:15:47 PM
 #5

So you basically want to double-spend(send same inputs twice)?

Hm? No. OP should use a fresh, unused input.

mtomcdev
Sr. Member
****
Offline Offline

Activity: 310
Merit: 250


View Profile
July 24, 2014, 11:21:38 PM
 #6

Okay, I'll try. I created f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b a few minutes ago and will use this as example.

Start up your Bitcoin-Qt/bitcoind v0.9 client and go Help - Debug. Enter: "getrawtransaction f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b".

You will then see the transaction as hex*:

Code:
01000000015d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8000000006b483045022100fd8c5227976363b79c6c2c72592e98148090ca26d89707f60dfaa19d5c59519f02207a34c47f2a55b9513d152520dd035fb9842d689c0c3350f4c0145e827e61604d01210391b373843e77f5ac1f05db4afb5151190e67cfee5a48f7925d71da7c5e919422ffffffff0100000000000000004e6a4c4b6f64617920697320466562203232203230313420616e642074686973206973206465785820402062697477617463682e636f2e2043686565727320616e64207374617920666c756666792100000000

This is the raw transaction with descriptions:

Code:
01000000          < Version
01                < Number of inputs
5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8  < Input transaction id
00000000          < Vout
00                < scriptSig length*
ffffffff          < Sequence number
01                < Number of outputs
0000000000000000  < Value
4e                < Push 78 byte (it's 78 hex encoded)
6a                < OP_RETURN
4c                < Push 76 byte (it's 76 hex encoded)
4974277320466562203232203230313420616e642074686973206973206465785820402062697477617463682e636f2e2043686565727320616c6c20616e64207374617920666c7566667921  < Payload with length of 76 byte
00000000          < Lock time

*I removed the actual scriptSig for this example.

You may notice that some data is flipped, for example the input transaction hash (compare: c8bb07dc4d2277ad506f16068f7cebc4cb481715332bd3d615ee3f46ab5f475d vs. 5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8).

To create an OP_RETURN transaction yourself, you may use this template:

Code:
0100000001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABB00000000ffffffff0100000000000000004e6a4cCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC00000000

Replace AA...A with the input transaction hash flipped, BB with vout, CC...C with your payload/message.

Go back to your debug console and type "decoderawtransaction XXX", whereby XXX is your modified transaction hex. If everything is fine, this should return some information about your transaction.

You may adjust the payload length by changing the 4e and 4c. Use a calculator to convert the numbers.

http://brainwallet.org/#converter has a hex to text and vice versa converter.

When you are finished, type: "signrawtransaction XXX", whereby XXX is your transaction hash. It should show a longer hash followed by "complete".

Copy that longer hash and type "sendrawtransaction YYY", whereby YYY is the signed transaction hex.

Last note: make sure you use only an input with 0.0001-ish BTC. It will all be considered as miner fee unless you add more outputs.

Hope that helps. Smiley


Edit: max length is now 40 byte, so you must adjust the length.

I am just looking this info, how to create an OP_RETURN transaction. Thanks dexX7 for posting this, it is very useful tutorial.
mtbitcoin
Legendary
*
Offline Offline

Activity: 876
Merit: 1000


Etherscan.io


View Profile
October 05, 2014, 07:51:12 AM
 #7

Thank you dexX7 

EtherScan::Ethereum Block Explorer | BlockScan::Coming Soon
b!z
Legendary
*
Offline Offline

Activity: 1582
Merit: 1007



View Profile
October 05, 2014, 09:05:57 PM
 #8

dexX7 you da real MVP
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
October 06, 2014, 05:08:27 PM
 #9

FWIW: you probably know the max. length to push was reduced to 40 byte on most pools.

A few days ago gidgreen published a small PHP tool to construct OP_RETURN transactions:

https://github.com/coinspark/php-OP_RETURN

That being said, abusing the blockchain as message storage is not very popular. Wink

FabioCarpi
Sr. Member
****
Offline Offline

Activity: 504
Merit: 250



View Profile
January 07, 2015, 08:53:35 PM
 #10

very interesting topic for me
but i typing getrawtransaction f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b 1 in my bitcoin-qt 0.10 and he says "No information available about transaction (code -5)"
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
January 08, 2015, 01:25:58 AM
 #11

very interesting topic for me
but i typing getrawtransaction f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b 1 in my bitcoin-qt 0.10 and he says "No information available about transaction (code -5)"

Are you on testnet or mainnet? This is a mainnet transaction.

FabioCarpi
Sr. Member
****
Offline Offline

Activity: 504
Merit: 250



View Profile
January 08, 2015, 11:22:44 AM
 #12

mainnet
shamoons
Full Member
***
Offline Offline

Activity: 165
Merit: 100



View Profile
March 12, 2015, 08:44:17 PM
 #13

Okay, I'll try. I created f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b a few minutes ago and will use this as example.

Start up your Bitcoin-Qt/bitcoind v0.9 client and go Help - Debug. Enter: "getrawtransaction f3784ea6df802af5de7bfd8dd6af8eb07cf317b873f09f895586cd09892e897b".

You will then see the transaction as hex*:

Code:
01000000015d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8000000006b483045022100fd8c5227976363b79c6c2c72592e98148090ca26d89707f60dfaa19d5c59519f02207a34c47f2a55b9513d152520dd035fb9842d689c0c3350f4c0145e827e61604d01210391b373843e77f5ac1f05db4afb5151190e67cfee5a48f7925d71da7c5e919422ffffffff0100000000000000004e6a4c4b6f64617920697320466562203232203230313420616e642074686973206973206465785820402062697477617463682e636f2e2043686565727320616e64207374617920666c756666792100000000

This is the raw transaction with descriptions:

Code:
01000000          < Version
01                < Number of inputs
5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8  < Input transaction id
00000000          < Vout
00                < scriptSig length*
ffffffff          < Sequence number
01                < Number of outputs
0000000000000000  < Value
4e                < Push 78 byte (it's 78 hex encoded)
6a                < OP_RETURN
4c                < Push 76 byte (it's 76 hex encoded)
4974277320466562203232203230313420616e642074686973206973206465785820402062697477617463682e636f2e2043686565727320616c6c20616e64207374617920666c7566667921  < Payload with length of 76 byte
00000000          < Lock time

*I removed the actual scriptSig for this example.

You may notice that some data is flipped, for example the input transaction hash (compare: c8bb07dc4d2277ad506f16068f7cebc4cb481715332bd3d615ee3f46ab5f475d vs. 5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8).

To create an OP_RETURN transaction yourself, you may use this template:

Code:
0100000001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABB00000000ffffffff0100000000000000004e6a4cCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC00000000

Replace AA...A with the input transaction hash flipped, BB with vout, CC...C with your payload/message.

Go back to your debug console and type "decoderawtransaction XXX", whereby XXX is your modified transaction hex. If everything is fine, this should return some information about your transaction.

You may adjust the payload length by changing the 4e and 4c. Use a calculator to convert the numbers.

http://brainwallet.org/#converter has a hex to text and vice versa converter.

When you are finished, type: "signrawtransaction XXX", whereby XXX is your transaction hex. It should show a longer hex followed by "complete".

Copy that longer hash and type "sendrawtransaction YYY", whereby YYY is the signed transaction hex.

Last note: make sure you use only an input with 0.0001-ish BTC. It will all be considered as miner fee unless you add more outputs.

Hope that helps. Smiley


Edit: max length is now 40 byte, so you must adjust the length.

Is it possible to have multiple vout's using this schema? If so, is it possible to have multiple OP_RETURNs in one transaction?
FabioCarpi
Sr. Member
****
Offline Offline

Activity: 504
Merit: 250



View Profile
March 12, 2015, 08:54:25 PM
 #14

just duplicate the part:

01                < Number of inputs
5d475fab463fee15d6d32b33151748cbc4eb7c8f06166f50ad77224ddc07bbc8  < Input transaction id
00000000          < Vout
00                < scriptSig length*
ffffffff          < Sequence number

why more op_return?
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
March 13, 2015, 11:48:57 AM
 #15

Is it possible to have multiple vout's using this schema? If so, is it possible to have multiple OP_RETURNs in one transaction?

Hi shamoons,

currently only one OP_RETURN output with a size of maximal 40 byte is considered as "accepted standard". Rather recently the default size of Bitcoin Core was raised to 80 byte, although I have no data whether this is adopted on a broader scale at this moment. The size is not a strict rule, and you'll find some OP_RETURN transactions with more than 200 byte on testnet, but on mainnet such transactions usually won't be relayed.

luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 795
Merit: 1000



View Profile
June 29, 2015, 11:50:18 PM
 #16

From my point of view, this is a nice illustration, the op might honor dexX7 well with some coins.

I just now today found out about this thread!  I stopped checking it after a few weeks, because well, a few weeks with no replies I figured it was dead.  I have since gotten somebody else to teach me; however, that was a solid write-up and I'm happy to throw some coin to dexX7... except I can't find an address for him!  dexX7, thank you for that great write-up!  Do you have an address I can tip?

dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
October 07, 2015, 02:47:44 PM
 #17

Hey luv2drnkbr,

thanks for the follow up! I kinda feel bad for "getting paid" for this kind of information, because I believe it serves the greater good, but you may use 1BzW1ETp2qZsi6ogAufmGsadnQzJcmVXet.

Thanks a lot! Smiley

And please let me know, if any step is unclear or needs to be refined.

As a related note:

The RPC "createrawtransaction" of Bitcoin Core 0.12 will be extended, and directly supports to create OP_RETURN transactions as follows:

Code:
bitcoin-cli "createrawtransaction" '[{"txid":"hash","vout":n}, ...] '{"data": "0123..."}'

coinableS
Legendary
*
Offline Offline

Activity: 1078
Merit: 1001



View Profile WWW
November 25, 2015, 03:15:57 AM
 #18

Hey luv2drnkbr,

thanks for the follow up! I kinda feel bad for "getting paid" for this kind of information, because I believe it serves the greater good, but you may use 1BzW1ETp2qZsi6ogAufmGsadnQzJcmVXet.

Thanks a lot! Smiley

And please let me know, if any step is unclear or needs to be refined.

As a related note:

The RPC "createrawtransaction" of Bitcoin Core 0.12 will be extended, and directly supports to create OP_RETURN transactions as follows:

Code:
bitcoin-cli "createrawtransaction" '[{"txid":"hash","vout":n}, ...] '{"data": "0123..."}'

Could you do an example for what would be entered for "data" and "0123...."?  It looks like the same format for a receiving address as a raw transaction.

Code:
createrawtransaction '[{"txid":"","vout":}]' '{"receive_address":0.0008}'

So instead of entering a receiving address and an amount one would enter '{"data":40_bytes}' ?

dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
December 10, 2015, 03:26:12 PM
 #19

So instead of entering a receiving address and an amount one would enter '{"data":40_bytes}' ?

Yes, basically it comes down to this. Smiley

Here is an example:

1. First, I list unspent outputs of the address I'm going to use.

Code:
bitcoin-cli listunspent 0 999999 '["1BxtgEa8UcrMzVZaW32zVyJh4Sg4KGFzxA"]'

Code:
[
  {
    "txid": "7425deeaebc2b13ff6c6d3cac78332693c86f46433403f65aef028bc88050583",
    "vout": 4,
    "address": "1BxtgEa8UcrMzVZaW32zVyJh4Sg4KGFzxA",
    "account": "Sender15",
    "scriptPubKey": "76a914784345e76ea29fd7bfe31f6f34622e154d0bb8fc88ac",
    "amount": 0.00110691,
    "confirmations": 558,
    "spendable": true
  }
]

2. Then I create the raw transaction. Note that I manually add a change output with a value of 0.00100691, so I pay a fee of exactly 0.0001 BTC. The payload for this transaction is the hex-encoded message "dexX7 @ bitcointalk.org".

Code:
bitcoin-cli createrawtransaction '[{"txid":"7425deeaebc2b13ff6c6d3cac78332693c86f46433403f65aef028bc88050583","vout":4}]' '{"data":"6465785837204020626974636f696e74616c6b2e6f7267","1BxtgEa8UcrMzVZaW32zVyJh4Sg4KGFzxA":0.00100691}'

Code:
010000000183050588bc28f0ae653f403364f4863c693283c7cad3c6f63fb1c2ebeade25740400000000ffffffff020000000000000000196a176465785837204020626974636f696e74616c6b2e6f726753890100000000001976a914784345e76ea29fd7bfe31f6f34622e154d0bb8fc88ac00000000

3. Then I sign the raw transaction.

Code:
bitcoin-cli signrawtransaction 010000000183050588bc28f0ae653f403364f4863c693283c7cad3c6f63fb1c2ebeade25740400000000ffffffff020000000000000000196a176465785837204020626974636f696e74616c6b2e6f726753890100000000001976a914784345e76ea29fd7bfe31f6f34622e154d0bb8fc88ac00000000

Code:
{
  "hex": "010000000183050588bc28f0ae653f403364f4863c693283c7cad3c6f63fb1c2ebeade2574040000006a47304402206eaf4d9c526a59bc391329dd62b6231035920ed23ba758a4d9b02d7738c0a77b0220404f00253e7d0202e64a7a8288dc83276218b91454d45ab618408f27b7135ba7012103c86e3c49a99dd688c6c6ad05d725b6a04ef19836b13d3e90ef282fc4f2f9ee71ffffffff020000000000000000196a176465785837204020626974636f696e74616c6b2e6f726753890100000000001976a914784345e76ea29fd7bfe31f6f34622e154d0bb8fc88ac00000000",
  "complete": true
}

4. And finally I broadcast the signed raw transaction.

Code:
bitcoin-cli sendrawtransaction 010000000183050588bc28f0ae653f403364f4863c693283c7cad3c6f63fb1c2ebeade2574040000006a47304402206eaf4d9c526a59bc391329dd62b6231035920ed23ba758a4d9b02d7738c0a77b0220404f00253e7d0202e64a7a8288dc83276218b91454d45ab618408f27b7135ba7012103c86e3c49a99dd688c6c6ad05d725b6a04ef19836b13d3e90ef282fc4f2f9ee71ffffffff020000000000000000196a176465785837204020626974636f696e74616c6b2e6f726753890100000000001976a914784345e76ea29fd7bfe31f6f34622e154d0bb8fc88ac00000000

Code:
b394e47f8141f725f25854d57e91fb67d91782dbe581b2f449990ba25a116d2d

5. Here is the result:

https://live.blockcypher.com/btc/tx/b394e47f8141f725f25854d57e91fb67d91782dbe581b2f449990ba25a116d2d/

Wink

Mitchell
Legendary
*
Offline Offline

Activity: 2184
Merit: 1267


Verified awesomeness ✔


View Profile
December 10, 2015, 08:51:04 PM
 #20

Is there anyway I can recreate this in the console of Electrum? It has a createrawtx function, but I can't find anything about it online.

Pages: [1] 2 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!