Post
Topic
Board Bitcoin Technical Support
Re: How to write messages into the blockchain?
by
DannyHamilton
on 20/02/2015, 22:47:41 UTC
You're going to need a service like this: http://www.cryptograffiti.info/ for your purpose.

Thanks, but I would like to know how to do it myself

About 10 seconds with the Google search engine turned up the following:

In python you could specify the OP_RETURN value as follows:

Code:
from binascii import unhexlify

msg = 'your message of max 40 chars'
# convert msg to OP_RETURN script in hexadecimal
hexed = "6a%x%s" % (len(msg), msg.encode('hex'))
# convert to binary encoding
script = unhexlify(hexed)
Set the value of the output to 0.0, replace the transaction script with the binary part above.

Do not forget to add enough fee and send the remainder to your change address.

If you can't figure out how to use an internet search engine, it is very unlikely that you'll be able to figure out how to write a program that will allow you to build raw bitcoin transactions.