Services Project Setup

Start building services on DAIN

In this section, we'll go through the steps to setup your service project, using the Services SDK.

Set up your project

Run the following command to initialize a new repository with a sample service and install the necessary dependencies:

dain init <service-name>

// make sure you move into your new project directory
cd <service-name>

npm install

This new repository will contain a sample service that you can use as a starting point for your own service. It will contain the following files:

Service files, Showing src with index.ts file and .env.development, dain.json. and package.json, and tsconfig.json

The src directory contains an index.ts file, which is the entry point for your service. The .env file is used to store your service's environment variables which we'll generate in the next step.

Generate environment variables

Head over to the Platform Dashboard and sign up for an account then click on the Organizations tab.

Highlighted Organizations tab on the Platform Dashboard

Click on "Create Organization" and fill out the form with your organization's details. This organization will represent your business or company on DAIN and help you build reputation in the network.

Once your organization is created, click on the Services tab.

Highlighted Services tab on the Platform Dashboard

Here you can create a service that will be associated with your organization. Click the "Create Service" button, fill out the service details form, and click "Create Service". Once created, click into the service to open the service dashboard.

Highlighted Keys and Signatories tab on the Service Dashboard

Click into the "Keys and Signatories" tab and click on "Add Signatory". From the dropdown that appears, select "API Key", fill in the form and click "Generate API Key". Copy the API Key and make sure to click click "Add Signatory". Save it, this is the last time you will see it.

Take that API Key and paste it in the .env.development file like this

DAIN_API_KEY=<copied-api-key>

Now, you're ready to get started building your first DAIN Service!