This basic guide will set you up quickly if you use Javascript / Typescript. For more info, you can check our main docs.

Step 0: Request organization

Request the creation of your Dfns organization, by filling out this form: http://ethparis.dfns.co

Step 1: Create Your User on the Dashboard

Once the Dfns team has registered you, you will receive a confirmation email. Follow the Getting Started guide to complete registration and access your account.

Step 2: Create an "Application" + "Service Account"

To use the Dfns API, you'll need to go to the dashboard, and create:

For the creation of the Service Account, you'll need to create a public/private keypair Credentials (will be used for secure authentication). This guide can help you do that, but the TLDR; is:

# Generate a ECDSA Private Key
openssl ecparam -genkey -name prime256v1 -noout -out dfns-creds.pem
# Generate the related Public Key
openssl pkey -in dfns-creds.pem -pubout -out dfns-creds.public.pem

Step 3: Create a backend service

Let's create a simple express server. We'll also use Dfns Typescript SDK. Install those npm packages:

# with npm
npm install express @dfns/sdk @dfns/sdk-keysigner

# with yarn
yarn add express @dfns/sdk @dfns/sdk-keysigner

In your server, this is how you initialize Dfns SDK:

const { DfnsApiClient } = require("@dfns/sdk");
const { AsymmetricKeySigner } = require("@dfns/sdk-keysigner");

const keySigner = new AsymmetricKeySigner({
    privateKey: `-----BEGIN EC PRIVATE KEY-----...-----END EC PRIVATE KEY-----`, // get the private key from your env or some place safe
    credId: "Y2k...BzcA", // credentials ID registered for the Service Account (created in step 3)
    appOrigin: "<http://localhost:3000>", // origin set in the Application (created in step 3)
});

const dfns = new DfnsApiClient({
  appId: "ap-2gg3n-bbr1t-9p78dlmcl4uikvnt", // ID of the Dfns Application (created in Step 3)
  baseUrl: "<https://api.dfns.ninja>", // Dfns API URl
  authToken: "eyJ...6qA", // Service Account token (created in step 3)
  signer: keySigner,
});

We'll create two endpoints on the server:

app.post("/wallet", async function (request, response) {
  const { network, name } = request.body
  const wallet = await dfns.wallets.createWallet({ body: { network, name } });
  response.send(wallet);
});