-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsend-funds.mjs
More file actions
36 lines (33 loc) · 1.02 KB
/
send-funds.mjs
File metadata and controls
36 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/send-funds.html
import { setupDashClient } from './setupDashClient.mjs';
const { sdk, addressKeyManager } = await setupDashClient();
const signer = addressKeyManager.getSigner();
const recipient =
process.env.RECIPIENT_PLATFORM_ADDRESS ||
'tdash1kr2ygqnqvsms509f78t4v3uqmce2re22jqycaxh4';
const amount = 500000n; // 0.000005 DASH
try {
const result = await sdk.addresses.transfer({
inputs: [
{
address: addressKeyManager.primaryAddress.bech32m,
amount,
},
],
outputs: [
{
address: recipient,
amount,
},
],
signer,
});
console.log(`Transaction broadcast! Sent ${amount} credits to ${recipient}`);
for (const [address, info] of result) {
const addr =
typeof address === 'string' ? address : address.toBech32m('testnet');
console.log(` ${addr}: ${info.balance} credits (nonce: ${info.nonce})`);
}
} catch (e) {
console.error('Something went wrong:\n', e.message);
}