Wallet Creation APIs
Wallet Creation Flow

A Bitski powered Ethereum wallet can be connected to your user’s account using a standard OAuth/OIDC login flow illustrated below. This flow can be managed by any standard OIDC client, or implemented directly.

Wallet Creation Flow

Node JS Example

Here is an example using the nodejs oauth4webapi client, but the flow will work using an OAuth client for any language. There are only two endpoints required, one to retrieve client credentials, and one to generate accounts for your user.

import * as oauth from 'oauth4webapi';

const ISSUER = 'https://account.bitski.com';
const { BITSKI_CLIENT_ID, BITSKI_CLIENT_SECRET } = platform.env;

export async function createAccount(userId: string): Promise<string> {

    // Generate client credentials for your service via standard OAuth
    const issuer = new URL(ISSUER);
    const as = await oauth
      .discoveryRequest(issuer)
      .then((response) => oauth.processDiscoveryResponse(issuer, response));

    const client: oauth.Client = {
      client_id: BITSKI_CLIENT_ID,
      client_secret: BITSKI_CLIENT_SECRET,
      token_endpoint_auth_method: 'client_secret_basic',
    };

    const resp = await oauth.clientCredentialsGrantRequest(as, client);
    const { access_token } = await resp.json();

    // Use client credentials to create a wallet for your user.
    // The `userId` here can be any string to identify the user.
    const newAccount = await fetch(`${ISSUER}/v2/federated-accounts`, {
      method: 'POST',
      headers: {
        authorization: `Bearer ${access_token}`,
        'User-Agent': 'account-creation-example/1.0.0',
        'content-type': 'application/json',
      },
      body: JSON.stringify({
        userId,
      }),
    });

    // The response contains an etherum `0x` address
    const { account } = await newAccount.json();

    return account;
}

Account Transfer

If enabled, users can transfer their wallets out of the WaaS offering by claiming their account and setting up login credentials. After claiming the account they can use it via the Bitski wallet applications on iOS, web, or browser extension, and use it across the ethereum ecosystem like normal.

Demo

See https://shadow-wallets-demo.pages.dev for an example of creating and claiming accounts via Twitter.

Claim Wallet Example