Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ede85a4
feat: add evo-sdk tutorials for read-only operations
thephez Oct 21, 2025
4fd0167
refactor: make output consistent and init client right away
thephez Oct 23, 2025
dadcce0
style: npm fmt
thephez Oct 23, 2025
edba3ae
feat: add more tutorials
thephez Oct 23, 2025
00c2189
feat: add working credit transfer tutorial
thephez Oct 23, 2025
db3ea5e
feat: add working identity credit withdrawal
thephez Oct 23, 2025
a967813
chore: update evo sdk to latest release
thephez Oct 28, 2025
48a4a01
feat: add name registration and document tutorials
thephez Oct 29, 2025
ab8d311
docs: update .env.example with recently added vars
thephez Oct 29, 2025
65d4a8d
feat: add minimal contract registration tutorial
thephez Oct 30, 2025
5e243eb
feat: add contract update tutorial
thephez Oct 30, 2025
2bc02bc
feat: create nft contract tutorial
thephez Oct 30, 2025
71769fe
feat: add some nft-related tutorials
thephez Oct 30, 2025
66272f6
feat: remaining nft tutorials and env.example updates
thephez Oct 30, 2025
811aee0
chore: update evo-sdk dependency
thephez Oct 30, 2025
ba40ef5
chore: update to evo sdk 3.1-dev.1
thephez Mar 4, 2026
97af81b
feat: add evo sdk client setup and identity register tutorial
thephez Mar 4, 2026
f83b28f
feat: migrate identity-retrieve and document-submit to evo-sdk ESM
thephez Mar 4, 2026
f91025b
docs: add links to tutorial docs pages
thephez Mar 4, 2026
e8912e5
feat: migrate document-retrieve and document-delete to evo-sdk ESM
thephez Mar 4, 2026
f8910da
feat: migrate document update to evo sdk
thephez Mar 4, 2026
ebf1349
fix: add bug workaround to identity create
thephez Mar 5, 2026
6ee7e97
feat: migrate contracts tutorials to evo-sdk ESM
thephez Mar 5, 2026
241f3e5
chore: delete old sdk tutorials
thephez Mar 5, 2026
1a857ab
feat: migrate connect and create-wallet to evo-sdk ESM
thephez Mar 5, 2026
a6f17b8
feat: migrate DPNS name tutorials to evo-sdk
thephez Mar 5, 2026
bd12099
chore: trivial updates
thephez Mar 5, 2026
dc8859f
chore: remove outdated files
thephez Mar 5, 2026
8b8b53e
chore: whitespace cleanup
thephez Mar 10, 2026
5d545a5
feat: migrate identity topup, transfer, and withdrawal to evo-sdk
thephez Mar 10, 2026
0df501d
feat: add identity update tutorials (add-key, disable-key) for evo-sdk
thephez Mar 10, 2026
52efdab
chore: remove unneeded files
thephez Mar 10, 2026
0bbcf42
chore: remove outdated files
thephez Mar 10, 2026
7e8e3fa
style: npm fmt updates
thephez Mar 10, 2026
57d18f8
docs: update README
thephez Mar 10, 2026
bc322f1
chore: typo fix
thephez Mar 10, 2026
fb12b3b
docs: update readme
thephez Mar 10, 2026
b832226
docs: readme update
thephez Mar 10, 2026
2b63d87
chore: remove old dash sdk from package.json
thephez Mar 10, 2026
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
38 changes: 38 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,41 @@ CONTRACT_ID='4BRJbxsDTFY4GJGrCqM6KUjv1wSQDBuUYiGkuzgcrD5d'
NETWORK='testnet'
# RECIPIENT_ID sets an identity ID to receive a credit transfer
RECIPIENT_ID='6cSbshXPYDA2CmBtD31X4uo7YLwtef4mVDt15zRok8Xg'

# Private keys for IDENTITY_ID in WIF format
# You can create an identity using the Dash Evo Tool and copy these keys from there
# https://github.com/dashpay/dash-evo-tool
MASTER_KEY_WIF=''
CRITICAL_KEY_WIF=''
TRANSFER_KEY_WIF=''

# DOCUMENT_ID is the ID of a document (obtained from document-submit output)
# Used for document-update and document-delete tutorials
DOCUMENT_ID=''

# NAME_LABEL is an optional username label for name registration (without .dash)
# If not provided, tutorials will generate a unique 20+ character label automatically
NAME_LABEL=''

# NFT Variables
# NFT_CONTRACT_ID comes from contract-register-nft output
NFT_CONTRACT_ID=''
# NFT_OWNER_ID is the identity ID that owns the NFT documents
# This should typically be the same as IDENTITY_ID above
NFT_OWNER_ID=''
# NFT_DOCUMENT_ID comes from nft-create output
# Used for nft-set-price, nft-transfer, etc.
NFT_DOCUMENT_ID=''

# NFT Marketplace Variables
# NFT_PRICE is the listing price in credits for marketplace operations
# Note: 1000 credits = 1 satoshi equivalent
NFT_PRICE=1000
# NFT_DOCUMENT_ID is the document ID to purchase from the marketplace
# This should be a different document than NFT_DOCUMENT_ID (you can't buy your own NFT)
NFT_DOCUMENT_ID=''
# NFT_BUYER_ID is the identity ID of the buyer (different from NFT_OWNER_ID)
NFT_BUYER_ID=''
# NFT_BUYER_KEY_WIF is the CRITICAL_KEY_WIF for the buyer's identity
# Required for purchase operations (AUTHENTICATION purpose key, not TRANSFER key)
NFT_BUYER_KEY_WIF=''
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.local/
node_modules/
.env
.DS_Store
13 changes: 0 additions & 13 deletions 1-Identities-and-Names/identity-register.js

This file was deleted.

44 changes: 44 additions & 0 deletions 1-Identities-and-Names/identity-register.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/register-an-identity.html
import { randomBytes } from 'node:crypto';
import { Identity, Identifier } from '@dashevo/evo-sdk';
import { setupDashClient } from '../setupDashClient.mjs';

const { sdk, keyManager, addressKeyManager } = await setupDashClient({
requireIdentity: false,
});

try {
// Build the identity shell with 5 standard public keys
const identity = new Identity(new Identifier(randomBytes(32)));
keyManager.getKeysInCreation().forEach((key) => {
identity.addPublicKey(key.toIdentityPublicKey());
});

// Create the identity on-chain, funded from the platform address
const result = await sdk.addresses.createIdentity({
identity,
inputs: [
{
address: addressKeyManager.primaryAddress.bech32m,
amount: 5000000n, // Credits to fund the new identity
},
],
identitySigner: keyManager.getFullSigner(),
addressSigner: addressKeyManager.getSigner(),
});

console.log(
'Identity registered!\nIdentity ID:',
result.identity.id.toString(),
);
} catch (e) {
// Known SDK bug: proof verification fails but the identity was created
// Issue: https://github.com/dashpay/platform/issues/3095
// Extract the real identity ID from the error message
const match = e.message?.match(/proof returned identity (\w+) but/);
if (match) {
console.log('Identity registered!\nIdentity ID:', match[1]);
} else {
console.error('Something went wrong:\n', e.message);
}
}
13 changes: 0 additions & 13 deletions 1-Identities-and-Names/identity-retrieve.js

This file was deleted.

20 changes: 20 additions & 0 deletions 1-Identities-and-Names/identity-retrieve.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/retrieve-an-identity.html
import { setupDashClient } from '../setupDashClient.mjs';

const { sdk, keyManager } = await setupDashClient();

// Identity ID from the identity create tutorial
const IDENTITY_ID = keyManager.identityId;

if (!IDENTITY_ID) {
throw new Error(
'No identity found. Run the "Register an Identity" tutorial first or provide an identity ID.',
);
}

try {
const identity = await sdk.identities.fetch(IDENTITY_ID);
console.log('Identity retrieved:\n', identity.toJSON());
} catch (e) {
console.error('Something went wrong:\n', e.message);
}
17 changes: 0 additions & 17 deletions 1-Identities-and-Names/identity-topup.js

This file was deleted.

28 changes: 28 additions & 0 deletions 1-Identities-and-Names/identity-topup.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/topup-an-identity-balance.html
import { setupDashClient } from '../setupDashClient.mjs';

const { sdk, addressKeyManager, keyManager } = await setupDashClient();
const signer = addressKeyManager.getSigner();

try {
// Identity ID from the identity create tutorial
const IDENTITY_ID = keyManager.identityId;
const identity = await sdk.identities.fetch(IDENTITY_ID);

const result = await sdk.addresses.topUpIdentity({
identity,
inputs: [
{
address: addressKeyManager.primaryAddress.bech32m,
amount: 200000n, // Credits to transfer
},
],
signer,
});

console.log(`Top-up result:
Start balance: ${identity.toJSON().balance}
Final balance: ${result.newBalance}`);
} catch (e) {
console.error('Something went wrong:\n', e.message);
}
31 changes: 0 additions & 31 deletions 1-Identities-and-Names/identity-transfer-credits.js

This file was deleted.

24 changes: 24 additions & 0 deletions 1-Identities-and-Names/identity-transfer-credits.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/transfer-credits-to-an-identity.html
import { setupDashClient } from '../setupDashClient.mjs';

const { sdk, keyManager } = await setupDashClient();
const { identity, signer } = await keyManager.getTransfer();

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

try {
await sdk.identities.creditTransfer({
identity,
recipientId,
amount: transferAmount,
signer,
});

const recipient = await sdk.identities.fetch(recipientId);
console.log('Recipient identity balance after transfer:', recipient.balance);
} catch (e) {
console.error('Something went wrong:\n', e.message);
}
60 changes: 60 additions & 0 deletions 1-Identities-and-Names/identity-update-add-key.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/update-an-identity.html
import {
IdentityPublicKeyInCreation,
KeyType,
Purpose,
SecurityLevel,
wallet,
} from '@dashevo/evo-sdk';
import {
setupDashClient,
clientConfig,
dip13KeyPath,
} from '../setupDashClient.mjs';

const { sdk, keyManager } = await setupDashClient();

// Fetch identity to determine the next available key ID
const { identity, signer } = await keyManager.getMaster();
const existingKeys = identity.toJSON().publicKeys;
const newKeyId = Math.max(...existingKeys.map((k) => k.id)) + 1;

console.log(`Adding key ${newKeyId} to identity ${keyManager.identityId}...`);

// Derive the new key using the standard DIP-13 path
const newKeyPath = await dip13KeyPath(
clientConfig.network,
keyManager.identityIndex,
newKeyId,
);
const newKeyInfo = await wallet.deriveKeyFromSeedWithPath({
mnemonic: clientConfig.mnemonic,
path: newKeyPath,
network: clientConfig.network,
});
const newKeyObj = newKeyInfo.toObject();

// Build the new public key
const newPublicKey = new IdentityPublicKeyInCreation({
keyId: newKeyId,
purpose: Purpose.AUTHENTICATION,
securityLevel: SecurityLevel.HIGH,
keyType: KeyType.ECDSA_SECP256K1,
data: Uint8Array.from(Buffer.from(newKeyObj.publicKey, 'hex')),
});

// Add the new key's WIF to the signer so it can co-sign
signer.addKeyFromWif(newKeyObj.privateKeyWif);

try {
await sdk.identities.update({
identity,
addPublicKeys: [newPublicKey],
signer,
});

const updatedIdentity = await sdk.identities.fetch(keyManager.identityId);
console.log('Identity updated:\n', updatedIdentity.toJSON());
} catch (e) {
console.error('Something went wrong:\n', e.message);
}
22 changes: 22 additions & 0 deletions 1-Identities-and-Names/identity-update-disable-key.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/update-an-identity.html
import { setupDashClient } from '../setupDashClient.mjs';

const { sdk, keyManager } = await setupDashClient();
const { identity, signer } = await keyManager.getMaster();

const KEY_ID = 99; // Replace with one of the identity's existing public key IDs

console.log(`Disabling key ${KEY_ID} on identity ${keyManager.identityId}...`);

try {
await sdk.identities.update({
identity,
disablePublicKeys: [KEY_ID], // Disable public key id KEY_ID
signer,
});

const updatedIdentity = await sdk.identities.fetch(keyManager.identityId);
console.log('Identity updated:\n', updatedIdentity.toJSON());
} catch (e) {
console.error('Something went wrong:\n', e.message);
}
37 changes: 0 additions & 37 deletions 1-Identities-and-Names/identity-withdraw-credits.js

This file was deleted.

28 changes: 28 additions & 0 deletions 1-Identities-and-Names/identity-withdraw-credits.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/withdraw-an-identity-balance.html
import { setupDashClient } from '../setupDashClient.mjs';

const { sdk, keyManager } = await setupDashClient();
const { identity, signer } = await keyManager.getTransfer();

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';
const amount = 190000n; // Credits to withdraw
const amountDash = Number(amount) / (1000 * 100000000);

console.log(`Withdrawing ${amount} credits (${amountDash} DASH)`);

try {
const remainingBalance = await sdk.identities.creditWithdrawal({
identity,
amount,
toAddress,
signer,
});

console.log(`Identity balance after withdrawal: ${remainingBalance} credits`);
} catch (e) {
console.error('Something went wrong:\n', e.message);
}
Loading