Created
January 6, 2018 12:20
-
-
Save oojr/28d608aa67aaf8858dc227498ef69218 to your computer and use it in GitHub Desktop.
bch sample code
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
// check balance | |
const blocktrail = require('blocktrail-sdk'); | |
const client = blocktrail.BlocktrailSDK({ | |
apiKey: '', | |
apiSecret: '', | |
network: 'BCC', | |
testnet: true | |
}); | |
client.address('2NFc5owQ7eeD2V3Qx4ZNuTxqcZ9LSrbwXP7', (err, address) => { | |
console.log('Total Balance', address.balance); | |
}); | |
client.blockLatest(function(err, block) { | |
console.log(block.hash); | |
}); | |
// send payment | |
const blocktrail = require('blocktrail-sdk'); | |
const client = blocktrail.BlocktrailSDK({ | |
apiKey: '', | |
apiSecret: '', | |
network: 'BCC', | |
testnet: true | |
}); | |
const value = blocktrail.toSatoshi(1.1); | |
let myWallet; | |
client.createNewWallet('mywallet', 'mypass', function(err, wallet, backupInfo) { | |
myWallet = wallet; | |
}); | |
client.initWallet('mywallet', 'mypass', function(err, wallet) { | |
console.log('Error', err); | |
console.log('Wallet', wallet); | |
const value = blocktrail.toSatoshi(3); | |
wallet.pay( | |
{ '2NGCeykHMPXEgyphnQLrX4UgmstGqRcyLqt': value }, | |
null, | |
false, | |
true, | |
blocktrail.Wallet.FEE_STRATEGY_BASE_FEE, | |
function(err, result) { | |
console.log('tx result', result); | |
} | |
); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment