Created
June 30, 2020 06:07
-
-
Save dashameter/fce17bad0d97ab644d0cff0acb98cbcc to your computer and use it in GitHub Desktop.
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
const Dash = require('dash'); | |
const clientOpts = { | |
network: 'testnet', | |
wallet: { | |
mnemonic: 'mnemonic with funds', | |
} | |
}; | |
const client = new Dash.Client(clientOpts); | |
async function sendFunds() { | |
const account = await client.wallet.getAccount(); | |
await account.isReady(); | |
try { | |
const transaction = account.createTransaction({ | |
recipient: 'yNPbcFfabtNmmxKdGwhHomdYfVs6gikbPf', // Evonet faucet | |
satoshis: 1000000, // 1 Dash | |
}); | |
// transaction.addData('correct horse battery staple') | |
const signedTransaction = account.sign(transaction) | |
const result = await account.broadcastTransaction(transaction); | |
console.log('Transaction broadcast!\nTransaction ID:', result); | |
} catch (e) { | |
console.error('Something went wrong:', e); | |
} finally { | |
client.disconnect(); | |
} | |
} | |
sendFunds(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
throws error: