Skip to content

Commit 037c02a

Browse files
thephezclaude
andauthored
feat: migrate send-funds tutorial to new evo-sdk (#65)
Replace old CommonJS wallet-account pattern with ESM sdk.addresses.transfer() using platform addresses (bech32m). Add RECIPIENT_PLATFORM_ADDRESS to .env.example and test case. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b1b32dc commit 037c02a

4 files changed

Lines changed: 52 additions & 26 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ DATA_CONTRACT_ID=''
1111
# RECIPIENT_ID is an identity ID for credit transfer tutorials
1212
RECIPIENT_ID=''
1313

14+
# RECIPIENT_PLATFORM_ADDRESS is a bech32m platform address (tdash1...) for send-funds tutorial
15+
RECIPIENT_PLATFORM_ADDRESS=''
16+
1417
# WITHDRAWAL_ADDRESS is a Core chain address for credit withdrawal tutorials
1518
WITHDRAWAL_ADDRESS=''
1619

send-funds.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

send-funds.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/send-funds.html
2+
import { setupDashClient } from './setupDashClient.mjs';
3+
4+
const { sdk, addressKeyManager } = await setupDashClient();
5+
const signer = addressKeyManager.getSigner();
6+
7+
const recipient =
8+
process.env.RECIPIENT_PLATFORM_ADDRESS ||
9+
'tdash1kr2ygqnqvsms509f78t4v3uqmce2re22jqycaxh4';
10+
const amount = 500000n; // 0.000005 DASH
11+
12+
try {
13+
const result = await sdk.addresses.transfer({
14+
inputs: [
15+
{
16+
address: addressKeyManager.primaryAddress.bech32m,
17+
amount,
18+
},
19+
],
20+
outputs: [
21+
{
22+
address: recipient,
23+
amount,
24+
},
25+
],
26+
signer,
27+
});
28+
console.log(`Transaction broadcast! Sent ${amount} credits to ${recipient}`);
29+
for (const [address, info] of result) {
30+
const addr =
31+
typeof address === 'string' ? address : address.toBech32m('testnet');
32+
console.log(` ${addr}: ${info.balance} credits (nonce: ${info.nonce})`);
33+
}
34+
} catch (e) {
35+
console.error('Something went wrong:\n', e.message);
36+
}

test/read-write.test.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ import {
1111
const state = {};
1212

1313
describe('Write tutorials (sequential)', { concurrency: 1 }, () => {
14+
// -----------------------------------------------------------------------
15+
// Phase 0: Address transfers (no identity needed)
16+
// -----------------------------------------------------------------------
17+
18+
it('send-funds', { timeout: 120_000 }, async () => {
19+
const result = await runTutorial('send-funds.mjs', { timeoutMs: 120_000 });
20+
assertTutorialSuccess(result, {
21+
name: 'send-funds',
22+
expectedPatterns: ['Transaction broadcast!'],
23+
errorPatterns: ['Something went wrong'],
24+
});
25+
});
26+
1427
// -----------------------------------------------------------------------
1528
// Phase 1: Identity
1629
// -----------------------------------------------------------------------

0 commit comments

Comments
 (0)