0.0.1 • Published 1 year ago
@djuno/wallet-sdk v0.0.1
Djuno Wallet SDK
A TypeScript SDK from Djuno that provides an easy way for developers to interact with Djuno's wallet API.
Features
- Fetch available blockchain networks
- Create and manage wallets
- Secure authentication via API key
- Built-in error handling
Installation
The SDK requires Node.js v16 or higher.
Install via npm:
npm install @djuno/wallet-sdkOr using yarn:
yarn add @djuno/wallet-sdkUsage
Initialize the Client
import { Client } from '@djuno/wallet-sdk';
const client = new Client({
endpointUrl: 'https://wallets.djuno.cloud',
accessKey: 'your-access-key',
});To create a wallet access key, visit the Djuno Panel.
Fetch Available Networks
Retrieve a list of supported blockchain networks:
client.networks().then((response) => {
if (response.status) {
console.log('Networks:', response.data);
} else {
console.error('Error:', response.message);
}
});Create a Wallet
const walletData = {
NetworkId: 1, // Replace with a valid network ID
Name: 'MyWallet',
UserId: 'user-123',
};
client.createWallet(walletData).then((response) => {
if (response.status) {
console.log('Wallet Created:', response.data);
} else {
console.error('Error:', response.message);
}
});Retrieve a Wallet
client.getWallet('wallet-id').then((response) => {
if (response.status) {
console.log('Wallet Details:', response.data);
} else {
console.error('Error:', response.message);
}
});Update a Wallet
const updateData = {
Name: 'UpdatedWalletName',
UserId: 'user-123',
};
client.updateWallet('wallet-id', updateData).then((response) => {
if (response.status) {
console.log('Wallet Updated:', response.data);
} else {
console.error('Error:', response.message);
}
});Configuration
The Client constructor accepts the following configuration options:
| Option | Type | Description |
|---|---|---|
endpointUrl | string | The base URL of the wallet API. Default: https://wallets.djuno.cloud |
accessKey | string | Required API key for authentication. |
version | string | API version. Default: v1 |
headers | Record<string, string> | Optional headers to include in requests. |
Error Handling
All methods return a GeneralResult<T> object with the following structure:
interface GeneralResult<T> {
status: boolean; // true if successful, false otherwise
message: string; // Response message or error description
data: T | null; // Response data if successful, otherwise null
}If an API request fails, the message field will contain the error details.
License
MIT License. See LICENSE for details.
0.0.1
1 year ago