Last active
July 15, 2019 09:03
-
-
Save bitgord/36d87064e3c17bfb1f6e6b36db104a55 to your computer and use it in GitHub Desktop.
Embed data in the bitcoin blockchain using butcher
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
// download bitcore-lib | |
npm install bitcore-lib | |
// require bitcore | |
var bitcore = require("bitcore-lib"); | |
// copy the code from BitPay's example to create an OP RETURN | |
var privateKey = new bitcore.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'); | |
var utxo = { | |
"txId" : "115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986", | |
"outputIndex" : 0, | |
"address" : "17XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV", | |
"script" : "76a91447862fe165e6121af80d5dde1ecb478ed170565b88ac", | |
"satoshis" : 50000 | |
}; | |
var transaction = new bitcore.Transaction() | |
.from(utxo) | |
.to('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000) | |
.addDate('put data you want to encode in blockchain;) | |
.sign(privateKey); | |
// log the transaction | |
console.log(transaction); | |
// When you run the file with node in your terminal you should get back a long string | |
// Copy the string and go to coinb.in | |
// Click on the broadcast tab and paste your OP RETURN raw transaction data | |
// You will get back a transaction id // Copy that | |
// Go to a blockchain explorer like btc.com and paste the transaction id | |
// In the tx you will see in the output section your decoded message, which has been embedded into the bitcoin blockchain | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment