Getting setup

Before you are able to deploy jobs on DCP, you need two types of API keys (called ‘keystores’).

  • An Identity Keystore: This keystore acts as your personal credentials for using DCP. Identity Keystores are also called Identity Keys, ID Keys, etc.

  • An Account Keystore: This keystore keeps track of the amount of value (called ‘credits’) that you have available.

Generating Keystores

You’re going to need an Identity Keystore if you are to deploy jobs in a Node.js application. The dcp-util library provides a way to generate keystores into your ~/.dcp directory (this is where the Wallet API looks for your keystores).

The following can be executed in your Terminal:

# Create the ~/.dcp directory if you don't have one
mkdir ~/.dcp
# Install `dcp-utils` npm package
npm install --global dcp-util
# Use the `mkad` command to generate keystores
# To generate an id keystore:
mkad new id # [recommended to use an empty password]

# You can also generate a default account keystore:
# mkad new default # [choose a password you won't forget]

# Verify that the keystores are present:
ls ~/.dcp

Note

Account Keystores generated will have a balance of 0. :::

Downloading Account Keystores

You can download Account Keystores from the DCP Portal, which also shows the amount left in your Account Keystore. Account Keystores are visible in the Accounts page on the Portal. Your account comes with a ‘default’ Account Keystore, which has a balance of 0 credits.

Accounts Tab UI

You can use any Account Keystore to earn credits using the Portal’s in-built Worker tab. Go to the Worker tab and click the green “Start” button. The worker starts using your computer’s processing power to complete computational jobs in exchange for credits that you can use to deploy your own work. You can stop this at any time by clicking “Stop” or by exiting the browser tab. You can earn credits in more ways at no cost.

Downloading from the Portal

You can download your Account Keystores from the Accounts page by clicking the hamburger icon on the account’s row, and then clicking “Download.” Then hamburger icon may be behind the lock icon if the keystore is in a locked state. It’s recommended to save this keystore file in your home directory at /home/<YOUR_USER_NAME>/.dcp/default.keystore (Linux & macOS), or C:\Users\<YOUR_USER_NAME>\.dcp\default.keystore (Windows). This is the default location where DCP’s APIs look to find your Account Keystore, to deploy a job.

Download Account Keystore

Note

It’s recommended to not change the name of the default.keystore file when you save it.

Using Keystores in web apps

By default, an Identity keystore will be generated in the browser for you when a job is deployed. However, one can be specified using Wallet.addId from the Wallet API.

Providing an Account Keystore to deploy jobs from your browser is straightforward. The dcp-client APIs automatically prompt you to upload an Account Keystore for payment when you start deploying the job.

A payment Keystore may also be set on a Job using the Job.setPaymentAccountKeystore method.

Note

The following is a temporary solution. It exposes your (revocable) Identity Keystore to the public. A planned long-term solution to this issue is to make DCP compatible with the OAuth protocol.

Using Keystores in Node.js apps

Using dcp-client APIs to build Node.js apps is even easier - the library looks for your keystores in the default location, .dcp in your home folder. This is what your .dcp folder looks like:

.dcp
|-- default.keystore
`-- id.keystore

If the dcp-client APIs can’t find your keystores, it displays an error stating where dcp-client searched for the files. You have to move your keystores into the appropriate file locations described earlier to launch a job without error.

Getting started

You are now ready to start deploying DCP jobs. Follow through the rest of the getting started guide to deploy your first DCP app.