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
14 changes: 0 additions & 14 deletions 1-Identities-and-Names/identity-retrieve-account-ids.js

This file was deleted.

2 changes: 1 addition & 1 deletion 1-Identities-and-Names/identity-transfer-credits.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { identity, signer } = await keyManager.getTransfer();

// Default recipient (testnet). Replace or override via RECIPIENT_ID.
const recipientId =
process.env.RECIPIENT_ID ?? '7XcruVSsGQVSgTcmPewaE4tXLutnW1F6PXxwMbo8GYQC';
process.env.RECIPIENT_ID || '7XcruVSsGQVSgTcmPewaE4tXLutnW1F6PXxwMbo8GYQC';
const transferAmount = 100000n; // Credits to transfer

try {
Expand Down
45 changes: 0 additions & 45 deletions 1-Identities-and-Names/identity-update-add-key.js

This file was deleted.

27 changes: 0 additions & 27 deletions 1-Identities-and-Names/identity-update-disable-key.js

This file was deleted.

2 changes: 1 addition & 1 deletion 1-Identities-and-Names/identity-update-disable-key.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { sdk, keyManager } = await setupDashClient();
const { identity, signer } = await keyManager.getMaster();

// Replace with one of the identity's existing public key IDs
const DISABLE_KEY_ID = Number(process.env.DISABLE_KEY_ID ?? 99);
const DISABLE_KEY_ID = Number(process.env.DISABLE_KEY_ID || 99);

console.log(
`Disabling key ${DISABLE_KEY_ID} on identity ${keyManager.identityId}...`,
Expand Down
2 changes: 1 addition & 1 deletion 1-Identities-and-Names/identity-withdraw-credits.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ console.log('Identity balance before withdrawal:', identity.balance);

// Default: testnet faucet address. Replace or override via WITHDRAWAL_ADDRESS.
const toAddress =
process.env.WITHDRAWAL_ADDRESS ?? 'yXWJGWuD4VBRMp9n2MtXQbGpgSeWyTRHme';
process.env.WITHDRAWAL_ADDRESS || 'yXWJGWuD4VBRMp9n2MtXQbGpgSeWyTRHme';
const amount = 190000n; // Credits to withdraw
const amountDash = Number(amount) / (1000 * 100000000);

Expand Down
2 changes: 1 addition & 1 deletion 1-Identities-and-Names/name-register.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { sdk, keyManager } = await setupDashClient();
const { identity, identityKey, signer } = await keyManager.getAuth();

// ⚠️ Change this to a unique name to register
const NAME_LABEL = process.env.NAME_LABEL ?? 'alice';
const NAME_LABEL = process.env.NAME_LABEL || 'alice';

try {
// Register a DPNS name for the identity
Expand Down
2 changes: 1 addition & 1 deletion 2-Contracts-and-Documents/contract-retrieve-history.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { sdk } = await setupDashClient();

// Default tutorial contract with history (testnet). Replace or override via DATA_CONTRACT_ID.
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ??
process.env.DATA_CONTRACT_ID ||
'5J4VPym1Bnc2Ap9bbo9wNw6fZLGsCzDM7ZScdzcggN1r';

try {
Expand Down
2 changes: 1 addition & 1 deletion 2-Contracts-and-Documents/contract-retrieve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { sdk } = await setupDashClient();

// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ??
process.env.DATA_CONTRACT_ID ||
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';

try {
Expand Down
2 changes: 1 addition & 1 deletion 2-Contracts-and-Documents/contract-update-history.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { identityKey, signer } = await keyManager.getAuth();
// Edit these values for your environment
// Your contract ID from the Register a Data Contract tutorial
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ?? 'YOUR_DATA_CONTRACT_ID';
process.env.DATA_CONTRACT_ID || 'YOUR_DATA_CONTRACT_ID';
const DOCUMENT_TYPE = 'note';

if (!DATA_CONTRACT_ID || DATA_CONTRACT_ID === 'YOUR_DATA_CONTRACT_ID') {
Expand Down
2 changes: 1 addition & 1 deletion 2-Contracts-and-Documents/contract-update-minimal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { identityKey, signer } = await keyManager.getAuth();
// Edit these values for your environment
// Your contract ID from the Register a Data Contract tutorial
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ?? 'YOUR_DATA_CONTRACT_ID';
process.env.DATA_CONTRACT_ID || 'YOUR_DATA_CONTRACT_ID';
const DOCUMENT_TYPE = 'note';

if (!DATA_CONTRACT_ID || DATA_CONTRACT_ID === 'YOUR_DATA_CONTRACT_ID') {
Expand Down
4 changes: 2 additions & 2 deletions 2-Contracts-and-Documents/document-delete.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const { identity, identityKey, signer } = await keyManager.getAuth();

// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ??
process.env.DATA_CONTRACT_ID ||
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';

// Replace with your existing document ID
const DOCUMENT_ID = process.env.DOCUMENT_ID ?? 'YOUR_DOCUMENT_ID';
const DOCUMENT_ID = process.env.DOCUMENT_ID || 'YOUR_DOCUMENT_ID';

try {
// Delete the document from the platform
Expand Down
2 changes: 1 addition & 1 deletion 2-Contracts-and-Documents/document-retrieve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { sdk } = await setupDashClient();

// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ??
process.env.DATA_CONTRACT_ID ||
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';

try {
Expand Down
2 changes: 1 addition & 1 deletion 2-Contracts-and-Documents/document-submit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { identity, identityKey, signer } = await keyManager.getAuth();

// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ??
process.env.DATA_CONTRACT_ID ||
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';

try {
Expand Down
4 changes: 2 additions & 2 deletions 2-Contracts-and-Documents/document-update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const { identity, identityKey, signer } = await keyManager.getAuth();

// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
const DATA_CONTRACT_ID =
process.env.DATA_CONTRACT_ID ??
process.env.DATA_CONTRACT_ID ||
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';

// Replace with your existing document ID from the Submit Documents tutorial
const DOCUMENT_ID = process.env.DOCUMENT_ID ?? 'YOUR_DOCUMENT_ID';
const DOCUMENT_ID = process.env.DOCUMENT_ID || 'YOUR_DOCUMENT_ID';

try {
// Fetch the existing document to get current revision
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/das
The included dev container provides a ready-to-use environment with Node.js, dependencies, and
editor tooling pre-configured. Open the repo in [GitHub
Codespaces](https://codespaces.new/dashpay/platform-tutorials) or locally with the [VS Code Dev
Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
Containers
extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).

On first launch the container installs dependencies and creates a starter `.env` file from
`.env.example`. Run `node create-wallet.mjs` to generate a mnemonic, then set `PLATFORM_MNEMONIC`
in your `.env` file to begin the tutorials.
`.env.example`. Run `node create-wallet.mjs` to generate a mnemonic, then set `PLATFORM_MNEMONIC` in
your `.env` file to begin the tutorials.

## Install

Expand Down Expand Up @@ -63,8 +64,8 @@ Some client configuration options are included as comments in

## Testing

Tests run each tutorial as a subprocess and validate its output. No test framework
dependencies are required — tests use the Node.js built-in test runner.
Tests run each tutorial as a subprocess and validate its output. No test framework dependencies are
required — tests use the Node.js built-in test runner.

Ensure your `.env` file is configured (see [`.env.example`](./.env.example)) before running tests.

Expand Down
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "platform-tutorials",
"version": "3.1-dev",
"description": "Tutorial code for https://docs.dash.org/platform",
"main": "connect.js",
"main": "connect.mjs",
"scripts": {
"fmt": "npx prettier@2 --write '**/*.{md,js,mjs}'",
"fmt": "npx prettier@3.8.1 --write '**/*.{js,mjs}'",
"lint": "npx -p typescript@4 tsc",
"test": "node --test --test-timeout=120000 test/read-only.test.mjs",
"test:read-only": "node --test --test-timeout=120000 test/read-only.test.mjs",
Expand All @@ -27,6 +27,8 @@
"dotenv": "17.3.1"
},
"devDependencies": {
"@types/mocha": "10.0.10",
"@types/node": "25.5.0",
"chai": "6.2.2",
"eslint": "8.45.0",
"mocha": "11.7.5"
Expand Down
Loading