Skip to content

Instantly share code, notes, and snippets.

@assafshomer
Created March 10, 2016 11:57
Show Gist options
  • Save assafshomer/89d72fae0de68689d9cc to your computer and use it in GitHub Desktop.
Save assafshomer/89d72fae0de68689d9cc to your computer and use it in GitHub Desktop.
bitcoinjs-lib op_return
wif='cNXxHLQwuzaLX7Z3apfSSEUDPPrQtUrwyzuaEZZakk2uWCcDS1Uo'
address='miq6AWvTYZJ63hJfh1W7zozHAf1URDv5pS'
unspent_txid = '067aabe97ff2e8051527d7f378266d046fd8e4c66e5b7dd671ec4e86b8a68cbb'
unspent_vout = 0
keyPair = bitcoin.ECPair.fromWIF(wif,network)
var txb = new bitcoin.TransactionBuilder(network)
var data = new Buffer('assafshomer')
var dataScript = bitcoin.script.nullDataOutput(data)
txb.addInput(unspent_txid, unspent_vout)
txb.addOutput(dataScript, 1000)
txb.sign(0, keyPair)
var txRaw = txb.build()
var txHex = txRaw.toHex()
console.log('hex',txHex)
//broadcasted via https://live.blockcypher.com/btc-testnet/pushtx/
// https://live.blockcypher.com/btc-testnet/tx/f1c4ed707c0800e0667e71b6923b18d0e3460ebc28f9a06721bda1ce1153ede6/
@stefanocudini
Copy link

what version of bitcoinjs-lib???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment