@zerohash-sdk/crypto-withdrawals-js
v1.3.1
Published
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Crypto Withdrawals product.
Readme
@zerohash-sdk/crypto-withdrawals-js
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Crypto Withdrawals product.
Connect Crypto Withdrawals provides a secure, customizable flow for withdrawing crypto assets directly within your application.
Installation
Via NPM (recommended)
npm install @zerohash-sdk/crypto-withdrawals-jsimport { CryptoWithdrawals } from '@zerohash-sdk/crypto-withdrawals-js';Via CDN
<script
type="module"
src="https://sdk.connect.xyz/crypto-withdrawals-web/index.js"
></script>Or import directly in your JavaScript code:
import { CryptoWithdrawals } from 'https://sdk.connect.xyz/crypto-withdrawals-web/index.js';Getting Started
1. Import the CryptoWithdrawals module
import { CryptoWithdrawals } from '@zerohash-sdk/crypto-withdrawals-js';2. Initialize and render the widget
const cryptoWithdrawals = new CryptoWithdrawals({
jwt: 'your-jwt-token',
env: 'prod',
theme: 'auto',
onCompleted: ({ withdrawalRequestId }) => {
console.log('Withdrawal completed:', withdrawalRequestId);
},
onError: ({ errorCode, reason }) => {
console.error('Error:', errorCode, 'Reason:', reason);
},
onClose: () => console.log('Widget closed'),
onEvent: ({ type, data }) => console.log('Event:', type, data),
onLoaded: () => console.log('Widget loaded and ready'),
});
await cryptoWithdrawals.render(document.getElementById('crypto-withdrawals-container'));
cryptoWithdrawals.destroy();2.1 Using TypeScript (optional)
import { CryptoWithdrawals, CryptoWithdrawalsConfig } from '@zerohash-sdk/crypto-withdrawals-js';
const config: CryptoWithdrawalsConfig = {
jwt: 'your-jwt-token',
env: 'cert',
onCompleted: ({ withdrawalRequestId }) => {
console.log(withdrawalRequestId);
},
};
const cryptoWithdrawals = new CryptoWithdrawals(config);
await cryptoWithdrawals.render(document.getElementById('container')!);API Reference
Configuration
| Prop | Type | Required | Default | Description |
| ------------- | -------------------------------------- | -------- | -------- | -------------------------------------------------------- |
| jwt | string | Yes | - | JWT token for authentication with Connect |
| env | "prod" \| "cert" \| "dev" \| "local" | No | "prod" | Target environment |
| theme | "auto" \| "light" \| "dark" | No | "auto" | Theme mode for the interface |
| onCompleted | ({ withdrawalRequestId }) => void | No | - | Callback when the withdrawal flow completes successfully |
| onError | ({ errorCode, reason }) => void | No | - | Callback for error events |
| onClose | () => void | No | - | Callback when the widget is closed |
| onEvent | ({ type, data }) => void | No | - | Callback for general events |
| onLoaded | () => void | No | - | Callback when the widget is loaded and ready |
Methods
render(container: HTMLElement): Promise<void>
updateConfig(config: Partial<CryptoWithdrawalsConfig>): void
destroy(): void
isRendered(): boolean
getConfig(): CryptoWithdrawalsConfig
Browser Support
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- All modern browsers with Web Components support
More Information & Support
For comprehensive documentation or support about Connect, visit our Documentation Page.
