Skip to content
Merged
15 changes: 2 additions & 13 deletions 1-Identities-and-Names/identity-register.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/register-an-identity.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const createIdentity = async () => {
return client.platform.identities.register();
Expand Down
14 changes: 2 additions & 12 deletions 1-Identities-and-Names/identity-retrieve-account-ids.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/retrieve-an-accounts-identities.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const client = new Dash.Client({
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
});
const client = setupDashClient();

const retrieveIdentityIds = async () => {
const account = await client.getWalletAccount();
Expand Down
6 changes: 2 additions & 4 deletions 1-Identities-and-Names/identity-retrieve.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/retrieve-an-identity.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const client = new Dash.Client({ network: process.env.NETWORK });
const client = setupDashClient();

const retrieveIdentity = async () => {
return client.platform.identities.get(process.env.IDENTITY_ID); // Your identity ID
Expand Down
15 changes: 2 additions & 13 deletions 1-Identities-and-Names/identity-topup.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/topup-an-identity-balance.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const topupIdentity = async () => {
const identityId = process.env.IDENTITY_ID; // Your identity ID
Expand Down
15 changes: 2 additions & 13 deletions 1-Identities-and-Names/identity-transfer-credits.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/transfer-credits-to-an-identity.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // only sync from mid-2023
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const transferCredits = async () => {
const identityId = process.env.IDENTITY_ID; // Your identity ID
Expand Down
16 changes: 3 additions & 13 deletions 1-Identities-and-Names/identity-update-add-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@ const Dash = require('dash');
const {
PlatformProtocol: { IdentityPublicKey, IdentityPublicKeyWithWitness },
} = Dash;
const dotenv = require('dotenv');
dotenv.config();

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const setupDashClient = require('../setupDashClient');

const client = setupDashClient();

const updateIdentityAddKey = async () => {
const identityId = process.env.IDENTITY_ID;
Expand Down
17 changes: 3 additions & 14 deletions 1-Identities-and-Names/identity-update-disable-key.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/update-an-identity.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const updateIdentityDisableKey = async () => {
const identityId = process.env.IDENTITY_ID;
const keyId = 2; // One of the identity's public key IDs
const keyId = 3; // One of the identity's public key IDs

// Retrieve the identity to be updated and the public key to disable
const existingIdentity = await client.platform.identities.get(identityId);
Expand Down
17 changes: 2 additions & 15 deletions 1-Identities-and-Names/name-register-alias.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/register-a-name-for-an-identity.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const aliasToRegister = ''; // Enter alias to register

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const registerAlias = async () => {
const platform = client.platform;
Expand Down
17 changes: 2 additions & 15 deletions 1-Identities-and-Names/name-register.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/register-a-name-for-an-identity.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const nameToRegister = ''; // Enter name to register

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const registerName = async () => {
const { platform } = client;
Expand Down
4 changes: 2 additions & 2 deletions 1-Identities-and-Names/name-resolve-by-name.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/retrieve-a-name.html
const Dash = require('dash');
const setupDashClient = require('../setupDashClient');

const client = new Dash.Client({ network: process.env.NETWORK });
const client = setupDashClient();

const nameToRetrieve = ''; // Enter name to retrieve

Expand Down
6 changes: 2 additions & 4 deletions 1-Identities-and-Names/name-resolve-by-record.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/retrieve-a-name.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const client = new Dash.Client({ network: process.env.NETWORK });
const client = setupDashClient();

const retrieveNameByRecord = async () => {
// Retrieve by a name's identity ID
Expand Down
6 changes: 2 additions & 4 deletions 1-Identities-and-Names/name-search-by-name.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/identities-and-names/retrieve-a-name.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const searchPrefix = 'a'; // Enter prefix character(s) to search for

const client = new Dash.Client({ network: process.env.NETWORK });
const client = setupDashClient();

const retrieveNameBySearch = async () => {
// Search for names (e.g. `user*`)
Expand Down
15 changes: 2 additions & 13 deletions 2-Contracts-and-Documents/contract-register-history.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/register-a-data-contract.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const registerContract = async () => {
const { platform } = client;
Expand Down
15 changes: 2 additions & 13 deletions 2-Contracts-and-Documents/contract-register-minimal.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/register-a-data-contract.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const registerContract = async () => {
const { platform } = client;
Expand Down
6 changes: 2 additions & 4 deletions 2-Contracts-and-Documents/contract-retrieve-history.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/retrieve-data-contract-history.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const client = new Dash.Client({ network: process.env.NETWORK });
const client = setupDashClient();

const retrieveContractHistory = async () => {
const contractId = process.env.CONTRACT_ID; // Your contract ID
Expand Down
6 changes: 2 additions & 4 deletions 2-Contracts-and-Documents/contract-retrieve.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/retrieve-a-data-contract.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const client = new Dash.Client({ network: process.env.NETWORK });
const client = setupDashClient();

const retrieveContract = async () => {
const contractId = process.env.CONTRACT_ID; // Your contract ID
Expand Down
17 changes: 3 additions & 14 deletions 2-Contracts-and-Documents/contract-update-history.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/update-documents.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const setupDashClient = require('../setupDashClient');

const client = setupDashClient();

const updateContract = async () => {
const { platform } = client;
Expand Down
15 changes: 2 additions & 13 deletions 2-Contracts-and-Documents/contract-update-minimal.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/update-documents.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const updateContract = async () => {
const { platform } = client;
Expand Down
20 changes: 2 additions & 18 deletions 2-Contracts-and-Documents/document-delete.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/delete-documents.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
wallet: {
mnemonic: process.env.MNEMONIC, // A Dash wallet mnemonic with testnet funds
unsafeOptions: {
skipSynchronizationBeforeHeight: process.env.SYNC_START_HEIGHT, // sync starting at this Core block height
},
},
apps: {
tutorialContract: {
contractId: process.env.CONTRACT_ID, // Your contract ID
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const deleteNoteDocument = async () => {
const { platform } = client;
Expand Down
14 changes: 2 additions & 12 deletions 2-Contracts-and-Documents/document-retrieve.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// See https://docs.dash.org/projects/platform/en/stable/docs/tutorials/contracts-and-documents/retrieve-documents.html
const Dash = require('dash');
const dotenv = require('dotenv');
dotenv.config();
const setupDashClient = require('../setupDashClient');

const clientOpts = {
network: process.env.NETWORK,
apps: {
tutorialContract: {
contractId: process.env.CONTRACT_ID, // Your contract ID
},
},
};
const client = new Dash.Client(clientOpts);
const client = setupDashClient();

const getDocuments = async () => {
return client.platform.documents.get('tutorialContract.note', {
Expand Down
Loading