Crypto Withdrawals SDK Guide
Enable users to withdraw stablecoins & crypto directly from your platform to their exchange account or wallet
Setup
Platforms can instantiate the Crypto Withdrawals SDK offering with AUTH included that eliminates the need to use the Account Link SDK flow.
Crypto Withdrawals differs from the Fund Withdrawals SDK in that it does NOT require fiat to convert into outgoing with rawals from the platform's float account. Crypto Withdrawals SDK is a non-converted withdrawal of crypto on the zerohash ledger to the customer's exchange account or wallet. Both SDKs utilize the same permission crypto-withdrawals. The difference is in the token's payload: supplying withdrawal_details (with quoted_asset and withdrawal_request_amount) triggers the Fund Withdrawals flow, whereas Crypto Withdrawals expects no withdrawal_details and lets the End Customer pick asset, network, and amount inside the SDK.
The key difference between this integration and the Account Link SDK + Withdraw SDK integration is the absence of the external account reference. Otherwise, the SDK flow is similar.
Flow
Crypto Withdrawals SDK - Request Access Token
Platform generates a client access token with the crypto-withdrawals permission. Unlike the Fund Withdrawals SDK, no withdrawal_details block is required; the End Customer selects asset, network, and amount inside the SDK.
| 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-withdrawals"] | Y |
reference_id | Platform reference id for a specific transaction | 0bd7f7f0-cf26-495f-b2df-e8afe8481ba3 | N |
Example POST /client_auth_token request:
{
"participant_code": "CUST01",
"permissions": ["crypto-withdrawals"],
"reference_id": "0bd7f7f0-cf26-495f-b2df-e8afe8481ba3"
}Starting the Crypto Withdrawals flow
After a successful POST /client_auth_token call, the next step is to open the Crypto Withdrawals modal via the zh-web-sdk. The example below shows a React integration; for native iOS/Android, use our native mobile SDKs which expose the same flow.
import { useMemo } from 'react';
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
export function WithdrawButton({ jwt }: { jwt: string }) {
// Create the SDK instance once, not on every render.
const sdk = useMemo(
() =>
new ZeroHashSDK({
zeroHashAppsURL: 'https://web-sdk.zerohash.com',
env: 'prod', // 'cert' | 'prod'
theme: 'auto', // 'light' | 'dark' | 'auto'
}),
[]
);
const openWithdrawal = () => {
sdk.openModal({
appIdentifier: AppIdentifier.CRYPTO_WITHDRAWALS,
jwt,
});
};
const closeWithdrawal = () => {
sdk.closeModal(AppIdentifier.CRYPTO_WITHDRAWALS);
};
return <button onClick={openWithdrawal}>Withdraw crypto</button>;
}The SDK walks the End Customer through the flow before the Review screen:
- Select source (only when the token has AUTH enabled) - either link an exchange to withdraw from, or choose manual entry (classic transfer)
- Select asset - the asset to withdraw
- Select network - the network the asset should be sent on
- Destination address - the destination wallet or exchange address (plus a memo/tag if the asset requires one). Only shown for manual entry; for exchange integrations the destination is resolved from the linked account
- Enter amount - the amount to withdraw, in the selected asset
The Customer then lands on the Review screen, which shows:
| Data Point | Description | Example |
|---|---|---|
| Withdraw | The amount and asset being withdrawn | 200 USDC |
| Network fee | The blockchain-assessed network fee on the withdrawal, in USD terms | $1.25 |
| Network | The network used to send the transaction | Ethereum |
| Send to | The destination address (truncated for display) | 0xa6b0…cB89 |
| You receive | The amount the destination address will receive, net of fees | 197.25 USDC |
Crypto Withdrawals SDK - Initiate Withdrawal
At this point, the End Customer is interacting with the front end SDK. The Customer will ultimately initiate the withdrawal.
Crypto Withdrawals SDK - Consume Webhook
Platform must be configured with a valid webhook URL in order to receive these webhooks. Please get in touch with a zerohash representative so that they can set this up for you. Your Platform will need to be specifically configured to receive these webhooks.
If you are configured for the AUTH experience, you will receive AUTH Withdrawal webhooks for the transaction lifecycle.
Crypto Withdrawals SDK - Query Withdrawals
The Platform can also query the GET /withdrawals/requests endpoint to view information about the Withdrawal. See the endpoint reference for the full response shape and example.
Updated 20 days ago