Skip to content

Instantly share code, notes, and snippets.

@dashameter
Created June 30, 2020 06:07
Show Gist options
  • Save dashameter/fce17bad0d97ab644d0cff0acb98cbcc to your computer and use it in GitHub Desktop.
Save dashameter/fce17bad0d97ab644d0cff0acb98cbcc to your computer and use it in GitHub Desktop.
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();
@dashameter
Copy link
Author

throws error:

Something went wrong: Error: Require one or multiple privateKeys to sign
    at KeyChain.sign (node_modules/@dashevo/wallet-lib/src/types/KeyChain/methods/sign.js:13:27)
    at Account.sign (node_modules/@dashevo/wallet-lib/src/types/Account/methods/sign.js:8:24)
    at sendFunds (sendFunds.js:21:39)
    at process._tickCallback (internal/process/next_tick.js:68:7)

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