- Instalar Node.js
- Rodar comando npm install
- Enjoy!
Link da apresentação: https://docs.google.com/presentation/d/1CGb01uev7BGgKAZGxs_NgsBZ0pjRYMP-irvPBlMak-k/edit#slide=id.p
Link da apresentação: https://docs.google.com/presentation/d/1CGb01uev7BGgKAZGxs_NgsBZ0pjRYMP-irvPBlMak-k/edit#slide=id.p
| const Bitcore = require('bitcore-lib'); | |
| if (true) Bitcore.Networks.defaultNetwork = Bitcore.Networks.testnet; | |
| var fromAddress = 'mrhcLBUaiNNu4icP4ytVw25iGuCJ73nMA3' | |
| , toAddress = 'mtsQKn4RWLzXJAndBMoUWUy5FGZ5XfbHUo' | |
| , amount = 1000000 | |
| , changeAddress = 'mqgBjbyqVbSwBv1PHHYjKD5nsS1Bww5Mz3' | |
| , transactionFee = 1000000; | |
| var Insight = require('bitcore-explorers').Insight | |
| , insight = new Insight() | |
| , privatekey = Bitcore.PrivateKey.fromString('2487f438d720ee741708f53815f5f90582d76501de414448e039e414728fca3c'); | |
| insight.getUnspentUtxos(fromAddress, function(err, utxos) { | |
| var transaction = new Bitcore.Transaction() | |
| .from(utxos) | |
| .to(toAddress, amount) | |
| .change(changeAddress) | |
| .fee(transactionFee) | |
| .sign(privatekey); | |
| var txSerialized = transaction.serialize(); | |
| insight.broadcast(txSerialized, function(err, transactionHash) { | |
| if (err) { | |
| console.log(err); | |
| } else { | |
| console.log(transactionHash); | |
| } | |
| }); | |
| }); |
| const Bitcore = require('bitcore-lib') | |
| , PrivateKey = Bitcore.PrivateKey; | |
| if (true) Bitcore.Networks.defaultNetwork = Bitcore.Networks.testnet; | |
| var privateKey = new PrivateKey() | |
| , publicKey = privateKey.toPublicKey() | |
| , address = publicKey.toAddress(); | |
| console.log('Private:', privateKey.toString()); | |
| console.log('Public address:', address.toString()); |
| { | |
| "name": "money-in-new-format", | |
| "version": "1.0.0", | |
| "description": "", | |
| "keywords": "money, new, format, bitcoin, cryptocurrency", | |
| "main": "broadcast.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "repository": { | |
| "type": "git", | |
| "url": "git+ssh://[email protected]/daa4e4cb974257dac6536ee0ab542d41.git" | |
| }, | |
| "author": "Anderson Juhasc", | |
| "license": "ISC", | |
| "bugs": { | |
| "url": "https://gist.github.com/daa4e4cb974257dac6536ee0ab542d41" | |
| }, | |
| "homepage": "https://gist.github.com/daa4e4cb974257dac6536ee0ab542d41", | |
| "dependencies": { | |
| "bitcore-explorers": "^1.0.1" | |
| } | |
| } |