Crypto Wallet Module (ABSK)
The cryptoWallet module provides ABSK (AI Blockchain Starter Kit) - a comprehensive solution for blockchain wallet management with AI-powered natural language processing.
Import
const absk = await brdzSDK.cryptoWallet;
Architecture Overview
ABSK operates on dual architecture:
- Manual Operations - Direct SDK method calls
- AI-Powered Operations - Natural language processing with conversational AI
Methods Overview
Manual Operations (5 methods)
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
createWallet | Create new crypto wallet | ✅ | POST /manual/wallets/crypto |
getUserWallets | Get user's wallets | ✅ | GET /manual/wallets/crypto/:user_id |
addChainAddress | Add blockchain address | ✅ | POST /manual/wallets/crypto/:bw_id/address |
getWalletAddresses | Get wallet addresses | ✅ | GET /manual/wallets/crypto/:bw_id/addresses |
deleteWallet | Delete wallet | ✅ | POST /manual/wallets/crypto/:bw_id/delete |
AI Agent Operations (4 methods)
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
processAIIntent | Main AI conversation endpoint | ✅ | POST /agent/wallets/process |
checkAIHealth | Check AI service status | ✅ | GET /agent/health |
clearAISession | Clear user conversation | ✅ | DELETE /agent/sessions/:user_id |
getActiveAISession | Get active conversation | ✅ | GET /agent/sessions/:user_id/active |
Transaction Operations (3 methods)
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
getTransactionHistory | Get user transaction history | ✅ | GET /transactions/:user_id/history |
cancelTransaction | Cancel pending transaction | ✅ | POST /transactions/:tx_id/cancel |
getTransactionDetails | Get transaction details | ✅ | GET /transactions/:tx_id/details |
Token & Balance Operations (5 methods)
| Method | Description | Auth Required | HTTP Endpoint |
|---|---|---|---|
importToken | Import token to wallets | ✅ | POST /tokens/import |
getWalletBalance | Get wallet balance | ✅ | GET /wallets/:wallet_id/balance |
getChainBalance | Get chain-specific balance | ✅ | GET /wallets/:wallet_id/balance/:chain_id |
getWalletTokens | Get imported tokens | ✅ | GET /tokens/:user_id |
removeToken | Remove imported token | ✅ | DELETE /tokens/:wallet_id/:asset_id |
Manual Operations
createWallet
Create a new cryptocurrency wallet with an initial chain address.
Syntax
const result = await absk.createWallet(walletData);
Parameters
interface WalletData {
user_id: number; // User ID who owns the wallet
wallet_name: string; // Display name for the wallet
chain_id: string; // Initial chain (sepolia, amoy, neon)
}
Returns
Promise<{
success: boolean;
message: string;
data: {
bw_id: number; // Blockchain Wallet ID
user_id: number;
wallet_name: string;
wallet_label: string;
network: string;
chain_id: string; // Initial chain added
created_at: string;
addresses: any[]; // Initially empty
address_count: number; // 0 initially
status: string; // 'setup_needed'
};
timestamp: string;
}>
Example
try {
const newWallet = await absk.createWallet({
user_id: 123,
wallet_name: "My DeFi Trading Wallet",
chain_id: "sepolia"
});
console.log('Wallet created:', newWallet.data.bw_id);
console.log('Initial chain:', newWallet.data.chain_id);
console.log('Status:', newWallet.data.status);
} catch (error) {
console.error('Wallet creation failed:', error.message);
}
getUserWallets
Get all cryptocurrency wallets owned by a specific user with complete address information.
Syntax
const result = await absk.getUserWallets(user_id);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | number | ✅ | User ID |
Returns
Promise<{
success: boolean;
message: string;
data: {
wallets: Array<{
bw_id: number;
user_id: number;
wallet_name: string;
wallet_label: string;
network: string;
is_primary: boolean;
created_at: string;
addresses: Array<{
address_id: number;
wallet_address: string;
chain_id: string;
created_at: string;
asset_count: number;
native_symbol: string;
has_assets: boolean;
}>;
address_count: number;
active_chains: number;
supported_chains: string[];
total_tokens: number;
total_assets: number;
total_value_usd: number;
status: string;
has_addresses: boolean;
}>;
summary: {
total_wallets: number;
active_wallets: number;
total_addresses: number;
total_chains: number;
};
};
timestamp: string;
}>
Example
try {
const wallets = await absk.getUserWallets(123);
console.log(`User has ${wallets.data.summary.total_wallets} wallets`);
wallets.data.wallets.forEach(wallet => {
console.log(`${wallet.wallet_name} (ID: ${wallet.bw_id})`);
console.log(`Chains: ${wallet.supported_chains.join(', ')}`);
console.log(`Status: ${wallet.status}`);
wallet.addresses.forEach(addr => {
console.log(` ${addr.chain_id}: ${addr.wallet_address} (${addr.asset_count} assets)`);
});
});
} catch (error) {
console.error('Failed to get wallets:', error.message);
}
addChainAddress
Add a blockchain address to an existing wallet for a specific chain.
Syntax
const result = await absk.addChainAddress(bw_id, chainData);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bw_id | number | ✅ | Blockchain Wallet ID |
chainData | object | ✅ | Chain configuration |
interface ChainData {
chain_id: 'sepolia' | 'amoy' | 'neon'; // Supported chains
}
Returns
Promise<{
success: boolean;
message: string;
data: {
address_id: number;
bw_id: number;
wallet_name: string;
wallet_address: string; // Generated blockchain address
chain_id: string;
created_at: string;
mnemonic: string; // Backup phrase (shown once)
native_symbol: string;
};
security_note: string;
timestamp: string;
}>
Example
try {
const address = await absk.addChainAddress(456, {
chain_id: 'amoy'
});
console.log('New address created:', address.data.wallet_address);
console.log('Chain:', address.data.chain_id);
console.log('Native symbol:', address.data.native_symbol);
// IMPORTANT: Backup the mnemonic phrase securely
console.log('Mnemonic (backup securely):', address.data.mnemonic);
console.log('Security note:', address.security_note);
} catch (error) {
if (error.message.includes('already exists')) {
console.error('Chain already added to this wallet');
} else {
console.error('Failed to add chain address:', error.message);
}
}
getWalletAddresses
Get all blockchain addresses for a specific wallet with asset information.
Syntax
const result = await absk.getWalletAddresses(bw_id);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bw_id | number | ✅ | Blockchain Wallet ID |
Returns
Promise<{
success: boolean;
message: string;
data: {
wallet_id: number;
addresses: Array<{
address_id: number;
bw_id: number;
wallet_address: string;
chain_id: string;
wallet_name: string;
wallet_label: string;
asset_count: number;
created_at: string;
native_symbol: string;
has_assets: boolean;
}>;
chain_groups: {
[chain_id: string]: Array<{
address_id: number;
wallet_address: string;
asset_count: number;
}>;
};
total_addresses: number;
supported_chains: string[];
total_assets: number;
};
timestamp: string;
}>
Example
try {
const addresses = await absk.getWalletAddresses(456);
console.log(`Wallet has ${addresses.data.total_addresses} addresses`);
console.log('Supported chains:', addresses.data.supported_chains);
addresses.data.addresses.forEach(addr => {
console.log(`${addr.chain_id}: ${addr.wallet_address}`);
console.log(` Assets: ${addr.asset_count} (${addr.native_symbol})`);
});
// Access by chain groups
Object.keys(addresses.data.chain_groups).forEach(chain => {
console.log(`${chain} addresses:`, addresses.data.chain_groups[chain]);
});
} catch (error) {
console.error('Failed to get wallet addresses:', error.message);
}
deleteWallet
Permanently delete a crypto wallet and all its addresses.
Syntax
const result = await absk.deleteWallet(bw_id, deleteData);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bw_id | number | ✅ | Blockchain Wallet ID |
deleteData | object | ✅ | Deletion confirmation |
interface DeleteData {
confirmation: 'delete'; // Must be exactly 'delete'
user_id: number; // User ID for verification
}
Returns
Promise<{
success: boolean;
message: string;
data: {
deleted_wallet: {
bw_id: number;
wallet_name: string;
wallet_label: string;
user_id: number;
};
};
timestamp: string;
}>
Example
try {
const result = await absk.deleteWallet(456, {
confirmation: 'delete',
user_id: 123
});
console.log('Wallet deleted:', result.data.deleted_wallet.wallet_name);
console.log('Wallet ID:', result.data.deleted_wallet.bw_id);
} catch (error) {
if (error.message.includes('confirmation')) {
console.error('Must provide exact confirmation: "delete"');
} else {
console.error('Failed to delete wallet:', error.message);
}
}
AI-Powered Operations
processAIIntent
Main AI conversation endpoint for natural language wallet operations.
Syntax
const result = await absk.processAIIntent(intentData);
Parameters
interface AIIntentData {
user_input: string; // Natural language input
user_id: number; // User ID
context?: any; // Optional conversation context
}
Returns
Promise<{
success: boolean;
agent_response: {
user_input: string;
ai_response: string;
message: string;
intent_type: string;
completed: boolean;
cancelled: boolean;
requires_onboarding: boolean;
requires_input: boolean;
missing_parameter?: string;
available_options?: any[];
suggested_actions?: any[];
data?: any;
execution_result?: any;
conversation_state: {
onboarding_required: boolean;
input_required: boolean;
completed: boolean;
cancelled: boolean;
has_data: boolean;
};
};
timestamp: string;
}>
HTTP Status Codes
| Status | Description | Agent State |
|---|---|---|
200 | Success - Operation completed | completed: true |
202 | Accepted - Requires onboarding | requires_onboarding: true |
206 | Partial Content - Needs more input | requires_input: true |
Examples
Wallet Creation via AI
try {
const result = await absk.processAIIntent({
user_input: "Create a new wallet called Trading Wallet with Sepolia chain",
user_id: 123
});
console.log('AI Response:', result.agent_response.ai_response);
console.log('Intent Type:', result.agent_response.intent_type);
if (result.agent_response.completed) {
console.log('Operation completed successfully!');
console.log('Result:', result.agent_response.execution_result);
} else if (result.agent_response.requires_input) {
console.log('AI needs more information:', result.agent_response.missing_parameter);
console.log('Available options:', result.agent_response.available_options);
}
} catch (error) {
console.error('AI intent failed:', error.message);
}
Balance Check via AI
const balanceCheck = await absk.processAIIntent({
user_input: "What's my USDC balance on Sepolia?",
user_id: 123
});
console.log('AI Response:', balanceCheck.agent_response.message);
console.log('Has Data:', balanceCheck.agent_response.conversation_state.has_data);
Multi-step Operation
// Step 1: Initial request
let response = await absk.processAIIntent({
user_input: "Send 10 USDC to my friend",
user_id: 123
});
// Step 2: If more input required
if (response.agent_response.requires_input) {
console.log('Missing:', response.agent_response.missing_parameter);
console.log('Options:', response.agent_response.available_options);
// Continue conversation
response = await absk.processAIIntent({
user_input: "Use my Trading Wallet and send to 0x742d35Cc...",
user_id: 123,
context: response.agent_response.conversation_state
});
}
checkAIHealth
Check AI agent service health and configuration status.
Syntax
const result = await absk.checkAIHealth();
Returns
Promise<{
success: boolean;
message: string;
service_status: {
database_connection: string;
service_response: string;
environment_checks: {
groq_configured: boolean;
usdc_sepolia: boolean;
usdc_amoy: boolean;
usdc_neon: boolean;
rpc_sepolia: boolean;
rpc_amoy: boolean;
rpc_neon: boolean;
};
fully_configured: boolean;
};
timestamp: string;
}>
Example
try {
const health = await absk.checkAIHealth();
console.log('AI Service Status:', health.service_status.service_response);
console.log('Fully Configured:', health.service_status.fully_configured);
// Check specific environment variables
const env = health.service_status.environment_checks;
if (!env.groq_configured) {
console.warn('GROQ API not configured - AI responses may be limited');
}
if (!env.fully_configured) {
console.warn('Some environment variables missing');
Object.keys(env).forEach(key => {
if (!env[key]) console.log(`Missing: ${key}`);
});
}
} catch (error) {
console.error('Health check failed:', error.message);
}
clearAISession
Clear user conversation sessions to reset AI agent memory.
Syntax
const result = await absk.clearAISession(user_id);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | number | ✅ | User ID |
Returns
Promise<{
success: boolean;
message: string;
data: {
user_id: number;
cleared_count: number;
};
timestamp: string;
}>
Example
try {
const result = await absk.clearAISession(123);
console.log('Cleared sessions:', result.data.cleared_count);
console.log('User ID:', result.data.user_id);
} catch (error) {
if (error.message.includes('ACCESS_DENIED')) {
console.error('Can only clear your own sessions');
} else {
console.error('Failed to clear sessions:', error.message);
}
}
getActiveAISession
Get active conversation context for a user.
Syntax
const result = await absk.getActiveAISession(user_id);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | number | ✅ | User ID |
Returns
Promise<{
success: boolean;
message: string;
data: {
user_id: number;
session: {
session_id: string;
current_intent: string;
context_data: any;
missing_parameters: string[];
created_at: string;
updated_at: string;
expires_at: string;
};
};
timestamp: string;
}>
Example
try {
const session = await absk.getActiveAISession(123);
console.log('Active session:', session.data.session.session_id);
console.log('Current intent:', session.data.session.current_intent);
console.log('Missing parameters:', session.data.session.missing_parameters);
} catch (error) {
if (error.message.includes('NO_ACTIVE_SESSION')) {
console.log('No active conversation found');
} else {
console.error('Failed to get session:', error.message);
}
}
Token & Balance Management
importToken
Import a custom token to all user wallets on a specific chain.
Syntax
const result = await absk.tokens.import(tokenData);
Parameters
interface TokenData {
chain_id: 'sepolia' | 'amoy' | 'neon';
asset_issuer: string; // Token contract address
user_id?: number; // Optional if from auth middleware
}
Returns
Promise<{
success: boolean;
message: string;
data: {
asset_ids: number[];
user_id: number;
chain_id: string;
token_address: string;
token_info: {
symbol: string;
name: string;
decimals: number;
};
imported_to_wallets: number;
wallet_details: Array<{
bw_id: number;
wallet_name: string;
asset_id: number;
}>;
imported_at: string;
};
timestamp: string;
}>
Example
try {
const result = await absk.tokens.import({
chain_id: 'sepolia',
asset_issuer: '0x9BF350fBaaA8c7200990B051809334c90778f435'
});
console.log('Token imported:', result.data.token_info.symbol);
console.log('Imported to', result.data.imported_to_wallets, 'wallets');
result.data.wallet_details.forEach(wallet => {
console.log(` ${wallet.wallet_name}: Asset ID ${wallet.asset_id}`);
});
} catch (error) {
if (error.message.includes('already imported')) {
console.error('Token already exists in wallets');
} else {
console.error('Import failed:', error.message);
}
}
getWalletBalance
Get comprehensive balance information for a specific wallet across all chains.
Syntax
const result = await absk.balance.getTotal(wallet_id);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
wallet_id | number | ✅ | Blockchain Wallet ID |
Returns
Promise<{
success: boolean;
message: string;
data: {
bw_id: number;
wallet_name: string;
total_value_usd: number;
total_addresses: number;
supported_chains: string[];
chains: {
[chain_id: string]: {
chain_id: string;
wallet_address: string;
native_balance: string;
native_symbol: string;
tokens: Array<{
symbol: string;
balance: string;
contract_address: string;
value_usd: number;
}>;
total_usd: number;
};
};
summary: {
total_chains: number;
total_addresses: number;
last_updated: string;
};
};
timestamp: string;
}>
Example
try {
const balance = await absk.balance.getTotal(456);
console.log('Wallet:', balance.data.wallet_name);
console.log('Total USD value:', balance.data.total_value_usd);
console.log('Supported chains:', balance.data.supported_chains);
Object.keys(balance.data.chains).forEach(chain => {
const chainData = balance.data.chains[chain];
console.log(`\n${chain.toUpperCase()}:`);
console.log(` Address: ${chainData.wallet_address}`);
console.log(` Native: ${chainData.native_balance} ${chainData.native_symbol}`);
chainData.tokens.forEach(token => {
console.log(` ${token.symbol}: ${token.balance} ($${token.value_usd})`);
});
});
} catch (error) {
if (error.message.includes('not found')) {
console.error('Wallet not found or not owned by user');
} else {
console.error('Failed to get balance:', error.message);
}
}
Transaction Management
getTransactionHistory
Get user's transaction history with pagination.
Syntax
const result = await absk.getTransactionHistory(user_id, params);
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | number | ✅ | User ID |
params | object | ❌ | Query parameters |
params.limit | number | ❌ | Records limit (1-100, default: 50) |
params.offset | number | ❌ | Records offset (default: 0) |
Returns
Promise<{
success: boolean;
message: string;
data: {
transactions: Array<{
transaction_id: string;
nonce: string;
transaction_type: string;
amount: number;
token: string;
from_chain: string;
to_chain: string;
recipient_address: string;
status: string;
tx_hash: string;
mint_tx_hash: string;
created_at: string;
updated_at: string;
is_crosschain: boolean;
is_cancellable: boolean;
}>;
pagination: {
current_page: number;
per_page: number;
offset: number;
total_returned: number;
has_more: boolean;
};
stats: {
total_transactions: number;
completed_transactions: number;
pending_transactions: number;
success_rate: number;
};
};
timestamp: string;
}>
Example
try {
const history = await absk.getTransactionHistory(123, {
limit: 10,
offset: 0
});
console.log('Transaction stats:', history.data.stats);
console.log(`Found ${history.data.transactions.length} transactions`);
history.data.transactions.forEach(tx => {
console.log(`${tx.transaction_type}: ${tx.amount} ${tx.token}`);
console.log(` ${tx.from_chain} → ${tx.to_chain} (${tx.status})`);
console.log(` Cancellable: ${tx.is_cancellable}`);
});
} catch (error) {
console.error('Failed to get transaction history:', error.message);
}
Complete Implementation Examples
AI-Powered Wallet Manager
class ABSKManager {
constructor(sdk) {
this.sdk = sdk;
this.absk = null;
this.isReady = false;
this.init();
}
async init() {
try {
this.absk = await this.sdk.cryptoWallet;
// Check AI health
const health = await this.absk.checkAIHealth();
if (!health.service_status.fully_configured) {
console.warn('AI service not fully configured');
}
this.isReady = true;
console.log('ABSK Manager ready');
} catch (error) {
console.error('ABSK initialization failed:', error.message);
}
}
async processNaturalLanguage(userInput, userId) {
if (!this.isReady) {
throw new Error('ABSK Manager not ready. Call init() first.');
}
try {
const result = await this.absk.processAIIntent({
user_input: userInput,
user_id: userId
});
const response = result.agent_response;
return {
message: response.ai_response,
type: this.getResponseType(response),
completed: response.completed,
requires_input: response.requires_input,
requires_onboarding: response.requires_onboarding,
missing_parameter: response.missing_parameter,
available_options: response.available_options,
execution_result: response.execution_result,
conversation_state: response.conversation_state
};
} catch (error) {
throw new Error(`AI processing failed: ${error.message}`);
}
}
getResponseType(response) {
if (response.completed) return 'completed';
if (response.requires_input) return 'input_required';
if (response.requires_onboarding) return 'onboarding_required';
if (response.cancelled) return 'cancelled';
return 'conversation';
}
async createWalletManually(userId, walletName, chainId) {
try {
const wallet = await this.absk.createWallet({
user_id: userId,
wallet_name: walletName,
chain_id: chainId
});
return wallet.data;
} catch (error) {
throw new Error(`Manual wallet creation failed: ${error.message}`);
}
}
async getWalletSummary(userId) {
try {
const walletsResult = await this.absk.getUserWallets(userId);
const detailedWallets = await Promise.all(
walletsResult.data.wallets.map(async (wallet) => {
try {
const balance = await this.absk.balance.getTotal(wallet.bw_id);
return {
...wallet,
balance_data: balance.data
};
} catch (error) {
return {
...wallet,
balance_data: null,
balance_error: error.message
};
}
})
);
return {
wallets: detailedWallets,
summary: walletsResult.data.summary
};
} catch (error) {
throw new Error(`Failed to get wallet summary: ${error.message}`);
}
}
async importTokenToWallets(chainId, contractAddress) {
try {
const result = await this.absk.tokens.import({
chain_id: chainId,
asset_issuer: contractAddress
});
return result.data;
} catch (error) {
throw new Error(`Token import failed: ${error.message}`);
}
}
async clearConversation(userId) {
try {
await this.absk.clearAISession(userId);
return { success: true };
} catch (error) {
throw new Error(`Failed to clear session: ${error.message}`);
}
}
}
Conversational Wallet Interface
class WalletChat {
constructor(containerId, abskManager) {
this.container = document.getElementById(containerId);
this.manager = abskManager;
this.userId = this.getCurrentUserId();
this.conversationActive = false;
this.setupUI();
}
setupUI() {
this.container.innerHTML = `
<div class="wallet-chat">
<div class="chat-header">
<h3>ABSK Wallet Assistant</h3>
<div class="status-indicator" id="ai-status">●</div>
</div>
<div class="chat-messages" id="chat-messages"></div>
<div class="chat-input-area">
<input type="text" id="chat-input"
placeholder="Ask me about your wallets..." />
<button id="send-btn">Send</button>
<button id="clear-btn">Clear</button>
</div>
</div>
`;
this.setupEventListeners();
this.checkAIStatus();
}
setupEventListeners() {
const input = document.getElementById('chat-input');
const sendBtn = document.getElementById('send-btn');
const clearBtn = document.getElementById('clear-btn');
sendBtn.onclick = () => this.sendMessage();
clearBtn.onclick = () => this.clearChat();
input.onkeypress = (e) => {
if (e.key === 'Enter') this.sendMessage();
};
}
async checkAIStatus() {
try {
const health = await this.manager.absk.checkAIHealth();
const statusEl = document.getElementById('ai-status');
if (health.service_status.fully_configured) {
statusEl.className = 'status-indicator online';
statusEl.title = 'AI service online';
} else {
statusEl.className = 'status-indicator warning';
statusEl.title = 'AI service partially configured';
}
} catch (error) {
const statusEl = document.getElementById('ai-status');
statusEl.className = 'status-indicator offline';
statusEl.title = 'AI service offline';
}
}
async sendMessage() {
const input = document.getElementById('chat-input');
const message = input.value.trim();
if (!message) return;
this.addMessage(message, 'user');
input.value = '';
input.disabled = true;
try {
const response = await this.manager.processNaturalLanguage(message, this.userId);
this.addMessage(response.message, 'assistant');
// Handle different response types
switch (response.type) {
case 'completed':
if (response.execution_result) {
this.addMessage('✅ Operation completed successfully!', 'system');
this.displayExecutionResult(response.execution_result);
}
break;
case 'input_required':
if (response.available_options?.length > 0) {
this.addOptionsButtons(response.available_options);
}
this.addMessage(`Missing: ${response.missing_parameter}`, 'info');
break;
case 'onboarding_required':
this.addMessage('Let me help you set up your first wallet!', 'system');
this.addOptionsButtons([
{ label: 'Create Sepolia Wallet', value: 'Create a wallet with Sepolia chain' },
{ label: 'Create Amoy Wallet', value: 'Create a wallet with Amoy chain' },
{ label: 'Create Neon Wallet', value: 'Create a wallet with Neon chain' }
]);
break;
case 'cancelled':
this.addMessage('Operation cancelled.', 'info');
break;
}
} catch (error) {
this.addMessage(`Error: ${error.message}`, 'error');
} finally {
input.disabled = false;
input.focus();
}
}
addMessage(text, sender) {
const messagesDiv = document.getElementById('chat-messages');
const messageDiv = document.createElement('div');
messageDiv.className = `message message-${sender}`;
messageDiv.textContent = text;
messagesDiv.appendChild(messageDiv);
messagesDiv.scrollTop = messagesDiv.scrollHeight;
}
addOptionsButtons(options) {
const messagesDiv = document.getElementById('chat-messages');
const optionsDiv = document.createElement('div');
optionsDiv.className = 'message-options';
options.forEach(option => {
const button = document.createElement('button');
button.textContent = option.label || option;
button.className = 'option-button';
button.onclick = () => {
document.getElementById('chat-input').value = option.value || option;
this.sendMessage();
};
optionsDiv.appendChild(button);
});
messagesDiv.appendChild(optionsDiv);
}
displayExecutionResult(result) {
if (result.data) {
const pre = document.createElement('pre');
pre.className = 'execution-result';
pre.textContent = JSON.stringify(result.data, null, 2);
document.getElementById('chat-messages').appendChild(pre);
}
}
async clearChat() {
try {
await this.manager.clearConversation(this.userId);
document.getElementById('chat-messages').innerHTML = '';
this.addMessage('Conversation cleared. How can I help you with your wallets?', 'assistant');
} catch (error) {
this.addMessage(`Error clearing conversation: ${error.message}`, 'error');
}
}
getCurrentUserId() {
return parseInt(localStorage.getItem('user_id')) || 1;
}
}
// Usage
const manager = new ABSKManager(brdzSDK);
const walletChat = new WalletChat('wallet-chat-container', manager);
Supported Blockchains
| Chain | Chain ID | Native Token | USDC Contract | Status |
|---|---|---|---|---|
| Sepolia Testnet | sepolia | ETH | 0x9BF350fBaaA8c7200990B051809334c90778f435 | ✅ Active |
| Polygon Amoy | amoy | POL | 0xC15239B6B9012F3225f9ebC091C7CE85FF31b983 | ✅ Active |
| Neon DevNet | neon | NEON | 0xB5234C0418402775bCA3f73c4B0B5bDd906FCA11 | ✅ Active |
Security Features
- Private Key Management: Encrypted storage with mnemonic backup
- Multi-Chain Support: Unified interface across blockchains
- AI Session Security: Conversation isolation per user
- Transaction Validation: Pre-execution validation and simulation
- Access Control: User-based wallet and session management
Error Handling
| Error Code | Description | Solution |
|---|---|---|
MISSING_FIELDS | Required parameters missing | Check required fields |
CHAIN_EXISTS | Chain already added to wallet | Use existing chain |
WALLET_NOT_FOUND | Invalid wallet ID or no access | Verify wallet ownership |
CONFIRMATION_REQUIRED | Deletion requires confirmation | Provide exact confirmation text |
ACCESS_DENIED | Insufficient permissions | Check user access rights |
SERVICE_UNAVAILABLE | AI agent not responding | Check service health |
Always implement proper error handling for both manual and AI operations, and provide user-friendly error messages.