This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Tutorial code for Dash Platform demonstrating how to interact with the Dash network using @dashevo/evo-sdk. Covers identities, DPNS names, data contracts, and documents.
Users need a funded identity before running write tutorials. Two paths:
- Standard —
node create-wallet.mjs(generates mnemonic + faucet URL) → fund via the printed URL →node 1-Identities-and-Names/identity-register.mjs - Fast — Use Dash Bridge to create a wallet and register an identity in one step, then set
PLATFORM_MNEMONICin.env
Run node view-wallet.mjs to confirm the identity is found before proceeding.
npm test # Read-only tests (~2min, safe to run anytime)
npm run test:read-write # Write tests (destructive, consumes testnet credits, ~5min)
npm run test:all # Both suites sequentially
npm run test:setup # Mocha tests for setupDashClient configuration
npm run lint # TypeScript type-check all JS files (tsc)
npm run fmt # Format with PrettierRunning a single tutorial directly:
node connect.mjs
node 1-Identities-and-Names/identity-retrieve.mjsRunning a single test file:
node --test --test-timeout=120000 test/read-only.test.mjsEach tutorial is a standalone .mjs ESM file with top-level await. The pattern is consistent:
import { setupDashClient } from '../setupDashClient.mjs';
const { sdk, keyManager } = await setupDashClient();
try {
// Tutorial logic — use sdk and keyManager
console.log(result.toJSON());
} catch (e) {
console.error('Something went wrong:\n', e.message);
}The central helper (~500 lines) that all tutorials import. It handles:
- Loading
.envviadotenv - BIP39 wallet derivation from
PLATFORM_MNEMONIC - DIP-13 key path derivation
- SDK instantiation (
createClient(network)) - Key manager setup — returns
{ sdk, keyManager, addressKeyManager }
keyManager.identityId resolves automatically from the mnemonic. keyManager.getAuth() returns the identity, key, and signer needed for signing transactions.
Note: The in-memory key pattern in
setupDashClientis for tutorials only — not suitable for production.
Tests use Node.js built-in test runner. Each test runs a tutorial as a subprocess via test/run-tutorial.mjs and validates:
- Exit code is 0
stdout/stderrmatch expected regex patterns- Process was not killed (no timeout)
test/assertions.mjs provides helpers like extractId() and extractKeyId() to capture values from output for use in subsequent dependent tests.
Read-write tests maintain a shared state object to pass IDs (contract IDs, document IDs, etc.) between sequential dependent tests.
All key derivation uses standard Dash paths. External wallets/tools must use the same paths for compatibility.
| Key type | Testnet path | Mainnet path |
|---|---|---|
| Platform address (BIP44) | m/44'/1'/0'/0/i |
m/44'/5'/0'/0/i |
| Identity master key (DIP-13) | m/9'/1'/5'/0'/0'/0'/0' |
m/9'/5'/5'/0'/0'/0'/0' |
| Identity keys 0–4 (DIP-13) | m/9'/1'/5'/0'/0'/0'/k' |
m/9'/5'/5'/0'/0'/0'/k' |
Where i = address index and k = key index (0=MASTER, 1=HIGH auth, 2=CRITICAL auth, 3=TRANSFER, 4=ENCRYPTION).
No BIP39 passphrase is used.
Copy .env.example to .env. Key variables:
| Variable | Purpose |
|---|---|
PLATFORM_MNEMONIC |
BIP39 mnemonic; required for all write operations |
NETWORK |
testnet (default) or mainnet |
DATA_CONTRACT_ID |
Output of contract-register-minimal.mjs |
DOCUMENT_ID |
Output of document-submit.mjs |
RECIPIENT_ID |
Identity ID for credit transfers |
RECIPIENT_PLATFORM_ADDRESS |
tdash1... address for send-funds |
Read-only tests skip gracefully when PLATFORM_MNEMONIC is unset.
- Root — shared utilities (
setupDashClient.mjs,connect.mjs,create-wallet.mjs,view-wallet.mjs,send-funds.mjs) 1-Identities-and-Names/— identity registration, top-up, key management, DPNS name registration/lookup2-Contracts-and-Documents/— data contract variants (minimal, indexed, binary, timestamps, history, NFT), document CRUD, NFT operationstest/— test runner, assertions, read-only and read-write test suitesdocs/— HTML/JS interactive tutorial runner (separate from Node tutorials)example-apps/— Standalone applications (Vite + React + TypeScript) that consume the tutorial SDK code. Each has its ownpackage.json, tsconfig, and toolchain — the conventions in this file (Node16 modules,airbnb-base, etc.) describe the root tutorial code only and do not apply insideexample-apps/. See each app's localCLAUDE.mdfor its conventions.
npm run lint runs tsc against the root tsconfig.json, which is scoped narrowly via include: ["./setupDashClient.mjs"] and transitively typechecks the tutorial .mjs files via allowJs + checkJs. Settings: strict: true, noUnusedLocals: true, Node16 module resolution. Apps under example-apps/ are excluded from this typecheck — they have their own tsconfigs and run their own tsc -b via each app's npm run build. ESLint uses airbnb-base. Prettier uses single quotes, 2-space tabs, trailing commas.