Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ DATA_CONTRACT_ID=''
# RECIPIENT_ID is an identity ID for credit transfer tutorials
RECIPIENT_ID=''

# RECIPIENT_PLATFORM_ADDRESS is a bech32m platform address (tdash1...) for send-funds tutorial
RECIPIENT_PLATFORM_ADDRESS=''

# WITHDRAWAL_ADDRESS is a Core chain address for credit withdrawal tutorials
WITHDRAWAL_ADDRESS=''

Expand Down
26 changes: 0 additions & 26 deletions send-funds.js

This file was deleted.

36 changes: 36 additions & 0 deletions send-funds.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
13 changes: 13 additions & 0 deletions test/read-write.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import {
const state = {};

describe('Write tutorials (sequential)', { concurrency: 1 }, () => {
// -----------------------------------------------------------------------
// Phase 0: Address transfers (no identity needed)
// -----------------------------------------------------------------------

it('send-funds', { timeout: 120_000 }, async () => {
const result = await runTutorial('send-funds.mjs', { timeoutMs: 120_000 });
assertTutorialSuccess(result, {
name: 'send-funds',
expectedPatterns: ['Transaction broadcast!'],
errorPatterns: ['Something went wrong'],
});
});

// -----------------------------------------------------------------------
// Phase 1: Identity
// -----------------------------------------------------------------------
Expand Down