Getting Started

Import SDK

import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';

Initialize SDK

To initialize the SDK, we need to instantiate the ZeroHashSDK class with a single required field zeroHashAppsURL in the object parameter and optional JWTs. The JWT tokens can be set later when opening the modal using the openModal method.

The URLs for certification and production are listed below:

Cert: https://web-sdk.cert.zerohash.com/
Prod: https://web-sdk.zerohash.com/

import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';

// with JWTs
const sdk = new ZeroHashSDK({
  zeroHashAppsURL: "<URL_HERE>",
  fiatDepositsJWT: "<JWT_HERE>", 
  cryptoBuyJWT: "<JWT_HERE>",
  cryptoSellJWT: "<JWT_HERE>",
  cryptoWithdrawalsJWT: "<JWT_HERE>",
  fiatWithdrawalsJWT: "<JWT_HERE>",
  userOnboardingJWT: "<JWT_HERE>", 
  profileJWT: "<JWT_HERE>"
});

// without JWTs
const sdk = new ZeroHashSDK({zeroHashAppsURL: "<URL_HERE>"});

Open Modal

To open the modal, we should call the openModal method with the required field appIdentifier in the object parameter and an optional JWT.

import { AppIdentifier } from 'zh-web-sdk';

// with JWT
sdk.openModal({appIdentifier: AppIdentifier.CRYPTO_BUY, jwt: "<JWT_HERE>"});

// without JWT
sdk.openModal({appIdentifier: AppIdentifier.CRYPTO_BUY});

Note: The JWT needs to be added in the parameter at least once. Once the JWT is passed, it will be set up in the application's context and won't need to be passed again unless you want to update it with a new one.