@zerohash-sdk/csp-crypto-withdrawals-js
v1.3.1
Published
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect CSP Crypto Withdrawals product.
Downloads
1,096
Readme
@zerohash-sdk/csp-crypto-withdrawals-js
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect CSP Crypto Withdrawals product.
Connect CSP Crypto Withdrawals provides a secure, customizable flow for withdrawing crypto assets directly within your application.
Installation
Via NPM (recommended)
npm install @zerohash-sdk/csp-crypto-withdrawals-jsimport { CspCryptoWithdrawals } from '@zerohash-sdk/csp-crypto-withdrawals-js';Via CDN
<script
type="module"
src="https://sdk.connect.xyz/csp-crypto-withdrawals-web/index.js"
></script>Or import directly in your JavaScript code:
import { CspCryptoWithdrawals } from 'https://sdk.connect.xyz/csp-crypto-withdrawals-web/index.js';Getting Started
1. Import the CspCryptoWithdrawals module
import { CspCryptoWithdrawals } from '@zerohash-sdk/csp-crypto-withdrawals-js';2. Initialize and render the widget
const cspCryptoWithdrawals = new CspCryptoWithdrawals({
jwt: 'your-jwt-token',
env: 'prod',
theme: 'auto',
onCompleted: ({ withdrawalRequestId, assetSymbol, amount, networkFee, withdrawalFee }) => {
console.log('Withdrawal completed:', withdrawalRequestId, amount, assetSymbol);
},
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 cspCryptoWithdrawals.render(document.getElementById('csp-crypto-withdrawals-container'));
cspCryptoWithdrawals.destroy();2.1 Using TypeScript (optional)
import { CspCryptoWithdrawals, CspCryptoWithdrawalsConfig } from '@zerohash-sdk/csp-crypto-withdrawals-js';
const config: CspCryptoWithdrawalsConfig = {
jwt: 'your-jwt-token',
env: 'cert',
onCompleted: ({ withdrawalRequestId, assetSymbol, amount, networkFee, withdrawalFee }) => {
console.log(withdrawalRequestId, amount, assetSymbol);
},
};
const cspCryptoWithdrawals = new CspCryptoWithdrawals(config);
await cspCryptoWithdrawals.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, assetSymbol, amount, networkFee, withdrawalFee }) => 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<CspCryptoWithdrawalsConfig>): void
destroy(): void
isRendered(): boolean
getConfig(): CspCryptoWithdrawalsConfig
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.
