Created
February 9, 2015 19:45
-
-
Save ryandotsmith/9f6a26c76ad852763d03 to your computer and use it in GitHub Desktop.
Chain.com OP_RETRURN Transaction - Create Bitcoin OP_RETURN Transactions in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bitcoin' | |
require 'chain' | |
Chain.block_chain = 'testnet3' | |
Bitcoin.network = :testnet3 | |
include Bitcoin::Builder | |
key = Bitcoin::Key.from_base58("cVVBKRBMoPLJSSMW7cM3hji7VmXz1zJWX3DypcjPcWpRBMEu2xF7") | |
builder = Bitcoin::Builder::TxBuilder.new | |
builder.input do |i| | |
i.prev_out("350d8714c734fdd75273259c4f06e1a5cb5ecebf182cf364a69e969c996384c1") | |
i.prev_out_index(1) | |
i.prev_out_script(["76a914a47fb04649d4b63d791462c0ac6b065dce8a994d88ac"].pack('H*')) | |
i.signature_key(key) | |
end | |
builder.output do |o| | |
o.value(0) | |
o.script {|s| s.type(:op_return); s.recipient(["hello from chain"].pack('H*'))} | |
end | |
builder.output do |o| | |
o.value(1000000) | |
o.script {|s| s.recipient(key.addr)} | |
end | |
puts Chain.send_transaction(builder.tx.to_payload.unpack('H*')[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment