Skip to content

dashpay/platform-tutorials

Repository files navigation

platform-readme-tutorials

SDK Version

Code for the tutorials found on the Platform documentation site.

Install

Note: NodeJS (v20+) must be installed to run the tutorial code.

Clone this repository

git clone https://github.com/dashpay/platform-readme-tutorials.git

Install project dependencies

Do a clean install of project dependencies:

npm ci

Usage

  1. Create an .env file (See .env.example for an example .env file). Set NETWORK to the desired network type (normally 'testnet').
  2. Check connection: node connect.js
  3. Create wallet: node create-wallet.js
  4. Go to the Testnet faucet and add funds to the address reported in the previous step
  5. Open the .env file (See .env.example for an example .env file) and set MNEMONIC to the wallet mnemonic from step 3.
  6. (Optional) To minimize wallet sync time, open your .env file and set SYNC_START_HEIGHT to a Core chain block height just below the height of your wallet's first transaction. Otherwise you can skip this step and use the default value from .env.example.

Proceed with the tutorials Identities and Names tutorials first and the Contracts And Documents tutorials next. They align with the tutorials section found on the documentation site. Many client configuration options are included as comments in setupDashClient.js if more advanced configuration is required.

After creating an identity, set the IDENTITY_ID value in your .env file to your new identity ID. After registering a data contract, set the CONTRACT_ID value in your .env file to your new contract ID. To do credit transfers between identities, create a second identity and set the RECIPIENT_ID value in your .env file to its ID.

Contributing

PRs accepted.

License

MIT