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 an object parameter and some optional fields such as the JWTs and the env you're targeting. The JWT tokens can be set later when opening the modal using the openModal method. If no env is set, it defaults to prod .

The URLs for certification and production are listed below:

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

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

// with JWTs
const sdk = new ZeroHashSDK({
. env: "cert", // cert || prod,
  cryptoDepositsJWT: "<JWT_HERE>",
  fiatDepositsJWT: "<JWT_HERE>", 
  cryptoBuyJWT: "<JWT_HERE>",
  cryptoSellJWT: "<JWT_HERE>",
  cryptoWithdrawalsJWT: "<JWT_HERE>",
  fiatWithdrawalsJWT: "<JWT_HERE>",
  userOnboardingJWT: "<JWT_HERE>",
  profileJWT: "<JWT_HERE>",
  fundJWT: "<JWT_HERE>",
  cryptoAccountLinkJWT: "<JWT_HERE>",
});

// without JWTs
const sdk = new ZeroHashSDK({env: "prod"});

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 (if you already defined the JWT when instantiating the ZeroHashSDK)
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.