Quick Start

Start Using SimpleID

If you haven't already, make sure to visit the Getting Started guide. You'll need an API Key going forward.

Install from NPM:

$ npm i simpleid-js-sdk

Once you've installed the package import the library:

import SimpleID from 'simpleid-js-sdk';

From there, you'll want to create an instance of SimpleID with your configuration options:

const simple = new SimpleID({
appOrigin: "https://www.simpleid.xyz",
scopes: ['store_write', 'publish_data'],
apiKey: "123-fake-api-key-456",
appName: "SimpleID",
network: "ropsten",
localRPCServer: 'http://localhost:7545'
});

Configuration Paramters

Parameter

Purpose

appOrigin

This is your verifiable application origin url

scopes

For Blockstack, you must define the scopes you'd like to use.

store_write means that you will store the user's data in Gaia storage. publish_data means the data will be publicly available.

apiKey

Your SimpleID API Key

network

The ethereum network you'd like to use. Choices are: mainnet, ropsten, kovan, local,and layer2. If you choose layer2, transactions will be funneled through Matic's layer 2 network and will finish in near real time.

localRPCServer

If you're running a local Ethereum node or testing with Ganache, you can point SimpleID to the local network via the network parameter, and you can specify the url here.

Now that SimpleID has been initialized, you can start using it. Let's start by authenticating a user. SimpleID is passwordless, so you do not need to specify whether a user is signing up or signing in. We take care of that for you. You will ultimately need to call the authenticate function twice: once with just the user's email address and once with the email + authentication token we send the user.

const payload = { email: userEmail};
const signup = await simple.authenticate(payload);

This will take the user's email address, check if the user is an existing user or a new user, and then send a one-time token. If the user is new, SimpleID will generate blockchain wallets, generate application specific encryption keys.

The user will receive the one-time token via email and will need to supply that to your application in some way. When you have that token, you can call the authenticate function again like this:

const payload = { email: userEmail, token: authToken };
const signup = await simple.authenticate(payload);

That's all there is to it. You're user will be signed in and ready to store data, interact with smart contracts, buy cryptocurrency, and broadcast transactions.

Let's move on to Ethereum-specifc functionality.