Use this developer guide for an efficient integration to the Crypto Account Link SDK
See core product page here
Acquire Access Token
To invoke the Crypto Account Link SDK, you'll need to acquire an access token requesting the crypto account link permission. Please see our detailed guide for instructions on how to setup calls to our endpoints. After this, you should request an access token specifying:
Field | Description | Example Value | Required? |
---|---|---|---|
participant_code | The 6-digit alpha numeric code associated with the Customer that is looking to withdraw (the response of the original POST /participants/customers/new call) | CUST01 | Y |
permissions | The array of permissions that will be granted to the returned JWT token | ["crypto-acccount-link"] | Y |
Example POST /client_auth_token
request:
{
"participant_code": "CUST01",
"permissions": ["crypto-account-link"]
}
After obtaining the access token, you can start using the SDK.
Web Application
We recommend to first read our Overview, Installation and Getting Started guides.
Example using React:
import React from 'react';
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
const App = () => {
const sdk = new ZeroHashSDK({
zeroHashAppsURL: "https://web-sdk.cert.zerohash.com",
cryptoAccountLinkJWT: "JWT_TOKEN_HERE"
});
sdk.openModal({ appIdentifier: AppIdentifier.CRYPTO_ACCOUNT_LINK })
return <></>;
}
export default App;
For a line by line explanation on how to integrate, please take a look at the following guide:
Mobile Application (WebView)
To use our SDK on mobile apps, you don't need to install or include zh-web-sdk
as a dependency in your project. We use a proxy server that calls the SDK internally to make it work for mobile applications. For more info, head to our Integration with Mobile Apps page and select the platform you're using to build your app.
Events
We forward events from the UI to the native app using the postMessage API. You can handle these events from the WebView component. Currently, these are the events we have:
Message | Meaning |
---|---|
SDK_MOBILE_READY | The SDK is ready to receive postMessage events (e.g OPEN_MODAL) |
CRYPTO_ACCOUNT_LINK_APP_LOADED | The SDK is loaded and visible to the customer. |
CRYPTO_ACCOUNT_LINK_CLOSE_BUTTON_CLICKED | The close (X) button was clicked in the top right corner of the UI. |
CRYPTO_ACCOUNT_LINK_EXTERNAL_ACCOUNT_CREATED | This event will be sent after the user successfully created a new external account. Your configured webhook will receive the updates as well. At this point, the external account will now be returned in the get external accounts endpoint. |
CRYPTO_ACCOUNT_LINK_COMPLETED | The flow was completed and internal calls were made successfully. |
CRYPTO_ACCOUNT_LINK_FAILED | The customer encountered an error that cannot be rectified in their current session. |
Messages
To control the WebView, you can also send messages using the postMessage API after receiving SDK_MOBILE_READY
from WebView. Currently, the accepted messages are:
Open Modal
Opens the modal with the JWT provided for identifier provided.
{type: "OPEN_MODAL", payload: {jwt: "<JWT_HERE>", appIdentifier: "crypto-account-link"}}
Close Modal
Closes the modal for identifier provided.
{type: "CLOSE_MODAL", payload:{appIdentifier: "crypto-account-link"}}
For more details on how to use our SDK with WebViews, please refer to Integration with Mobile Apps