Skip to content
Closed
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
32 changes: 21 additions & 11 deletions create-wallet.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
"use strict";

// See https://dashplatform.readme.io/docs/tutorial-create-and-fund-a-wallet
const Dash = require('dash');
const Dash = require("dash");

const DomStorage = require("dom-storage");
const myLocalStorage = new DomStorage("./db.json", { strict: true, ws: " " });
const JsonStorage = require("json-storage").JsonStorage;
const store = JsonStorage.create(myLocalStorage, "dash", { stringify: true });
store.getItem = store.get;
store.setItem = store.set;

const clientOpts = {
network: 'testnet',
network: "testnet",
wallet: {
adapter: store,
mnemonic: null, // this indicates that we want a new wallet to be generated
// if you want to get a new address for an existing wallet
// replace 'null' with an existing wallet mnemonic
offlineMode: true, // this indicates we don't want to sync the chain
// it can only be used when the mnemonic is set to 'null'
// if you want to get a new address for an existing wallet
// replace 'null' with an existing wallet mnemonic
offlineMode: true, // this indicates we don't want to sync the chain
// it can only be used when the mnemonic is set to 'null'
},
};

Expand All @@ -19,16 +29,16 @@ const createWallet = async () => {

const mnemonic = client.wallet.exportWallet();
const address = account.getUnusedAddress();
console.log('Mnemonic:', mnemonic);
console.log('Unused address:', address.address);
console.log("Mnemonic:", mnemonic);
console.log("Unused address:", address.address);
};

createWallet()
.catch((e) => console.error('Something went wrong:\n', e))
.catch((e) => console.error("Something went wrong:\n", e))
.finally(() => client.disconnect());

// Handle wallet async errors
client.on('error', (error, context) => {
client.on("error", (error, context) => {
console.error(`Client error: ${error.name}`);
console.error(context);
});
});
30 changes: 29 additions & 1 deletion package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
},
"homepage": "https://github.com/dashevo/platform-readme-tutorials#readme",
"dependencies": {
"dash": "^3.22.7"
"dash": "^3.22.7",
"dom-storage": "^2.1.0",
"json-storage": "^2.1.2"
},
"devDependencies": {
"dotenv": "^16.0.0",
Expand Down