An interactive command-line wallet application demonstrating comprehensive Tari JavaScript SDK functionality. This example showcases real-world wallet operations, transaction management, and network interactions in a user-friendly console interface.
🎯 Core Wallet Operations
- Interactive menu system with intuitive navigation
- Real-time balance checking with detailed breakdowns
- Transaction sending with fee estimation
- Address generation and validation
- Transaction history with status tracking
🔄 Real-Time Updates
- Live transaction notifications
- Balance change alerts
- Network connection status monitoring
- Blockchain sync progress tracking
🌐 Multi-Network Support
- Mainnet, testnet, and nextnet configurations
- Automatic peer discovery and connection management
- Network health monitoring and diagnostics
🔒 Security Features
- Platform-specific secure storage integration
- Automatic Tauri optimization detection
- Comprehensive error handling and validation
- Secure resource cleanup and management
- Node.js: 18.0.0 or higher
- npm: 8.0.0 or higher
- Tari SDK: Built and available in the workspace
# From the examples/node-console directory
npm install
# Build the application
npm run build# Start with default settings (testnet)
npm start
# Or run in development mode
npm run dev# Specify network
npm start -- --network testnet
npm start -- --network mainnet
# Custom storage path
npm start -- --storage-path ./my-wallet-data
# Set log level
npm start -- --log-level debug
# Disable auto-connect
npm start -- --no-auto-connect
# Show help
npm start -- --help# Testnet wallet with debug logging
npm start -- --network testnet --log-level debug
# Mainnet wallet with custom storage
npm start -- --network mainnet --storage-path ~/tari-wallet
# Development mode with auto-reload
npm run dev -- --network testnet --log-level infoOnce started, the console wallet provides an interactive menu:
🚀 Tari Console Wallet
Platform Information:
• Runtime: node
• Storage: SecretService
• Security Level: high
• Node.js: v18.19.0
? What would you like to do? (Use arrow keys)
❯ 💰 Check Balance
📍 Show Address
💸 Send Transaction
📋 Transaction History
💵 Estimate Fees
✅ Validate Address
🔄 Sync Wallet
🌐 Network Status
⚙️ Settings
🚪 Exit
Displays comprehensive balance information:
- Available funds (spendable immediately)
- Pending incoming transactions
- Pending outgoing transactions
- Time-locked funds
- Total balance calculation
Shows your wallet address in both formats:
- Base58: Traditional long format for technical use
- Emoji: User-friendly 33-emoji format for easy sharing
Interactive transaction creation with:
- Recipient address validation (base58 or emoji)
- Amount input with balance verification
- Optional message attachment
- Fee estimation and confirmation
- Real-time transaction status updates
Displays recent transactions with:
- Transaction type (incoming/outgoing)
- Amount and status
- Date and transaction ID
- Formatted table view for easy reading
Calculate transaction fees before sending:
- Fee estimation for any amount
- Fee per gram calculation
- Total cost breakdown
- Fee percentage analysis
Verify Tari address formats:
- Validates both base58 and emoji formats
- Shows address in both formats if valid
- Network compatibility checking
Synchronize with the Tari network:
- Blockchain synchronization
- Progress monitoring
- Error handling and retry logic
Network connectivity information:
- Connection status and peer count
- Local vs network block height
- Sync status indication
- Network type confirmation
Display current configuration:
- Network and storage settings
- Platform and security information
- Backend optimization status
The console wallet provides live updates for:
🎉 Received 1.000000 T from 7e2b8c9d4f5a...
💸 Sent 0.500000 T to abc123def456...
💰 Balance updated: 15.250000 T available
🌐 Network: Connected
🔄 Sync: 50% complete
You can configure the wallet using environment variables:
# Network selection
export TARI_NETWORK=testnet
# Custom storage path
export TARI_STORAGE_PATH=~/my-tari-wallet
# Log level
export TARI_LOG_LEVEL=debug
# Base node configuration (optional)
export TARI_BASE_NODE_ADDRESS=/ip4/127.0.0.1/tcp/18189
export TARI_BASE_NODE_PUBLIC_KEY=your_base_node_public_keyCreate a wallet-config.json file:
{
"network": "testnet",
"storagePath": "./wallet-data",
"logLevel": "info",
"autoConnect": true,
"baseNode": {
"address": "/ip4/testnet.node.tari.com/tcp/18189",
"publicKey": "base_node_public_key"
}
}For testnet development, you'll need test funds:
- Refer to the main Tari documentation for testnet fund sources
- Look for official testnet faucets
- Use the emoji format for easier copying
- Look for community-maintained testnet faucets
- Check testnet mining pools if available
- Refer to Tari development resources
- Set up a Tari miner on testnet
- Mine directly to your wallet address
- Requires additional setup and resources
The console wallet includes comprehensive error handling:
Insufficient Funds
💰 Insufficient funds for this transaction
- Get testnet funds from official sources or faucets
- Check your balance before sending
Invalid Address
📍 Invalid recipient address format
- Verify the address format (base58 or emoji)
- Use the address validation feature
Network Connection
🌐 Network connection error - check your internet
- Verify internet connectivity
- Check if base nodes are reachable
- Try syncing the wallet
Enable debug logging for troubleshooting:
npm start -- --log-level debugThis provides detailed information about:
- FFI operations and performance
- Network communications
- Storage operations
- Error details and stack traces
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run the built application
node dist/index.js
# Or run directly with tsx
npm run devexamples/node-console/
├── src/
│ ├── index.ts # Main application entry point
│ ├── commands.ts # CLI command definitions
│ └── wallet.ts # Wallet management class
├── dist/ # Compiled JavaScript output
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- New Menu Option: Add to the main menu choices in
showMainMenu() - New Command: Implement the handler method in the
ConsoleWalletclass - CLI Options: Add new options to the Commander program
- Error Handling: Add specific error handling for new operations
# Test with different networks
npm start -- --network testnet
npm start -- --network mainnet
# Test error conditions
npm start -- --network invalid-network
# Test with different storage paths
npm start -- --storage-path /tmp/test-walletThe console wallet automatically detects and optimizes for your platform:
When running in a Tauri application:
- 60% lower memory usage
- 10x faster startup time
- Hardware-backed security
- Minimal attack surface
When running in Electron:
- Context isolation security
- IPC rate limiting
- Secure storage integration
When running in pure Node.js:
- Direct native access
- Optimized FFI performance
- Platform-specific storage
- Seed phrases are encrypted using platform-specific secure storage
- Never store seed phrases in plain text
- Always backup seed phrases securely
- Use secure connections to base nodes
- Verify base node authenticity when possible
- Monitor for unusual network activity
- Input validation for all user inputs
- Rate limiting for network operations
- Secure cleanup of sensitive data
Native module compilation errors:
# macOS
xcode-select --install
# Linux
sudo apt-get install build-essential libsecret-1-dev
# Windows
npm install --global windows-build-toolsPermission errors:
# Fix npm permissions
npm config set cache ~/.npm --global
sudo chown -R $(whoami) ~/.npmStorage backend unavailable:
- Install platform-specific secure storage
- Check system keyring services
- Use fallback storage for development
Network connection failures:
- Check internet connectivity
- Verify base node configuration
- Try automatic peer discovery
- Check Console Output: Look for detailed error messages
- Enable Debug Logging: Use
--log-level debugfor more information - GitHub Issues: Report bugs at the repository
We welcome contributions! To contribute to this example:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Update documentation
- Submit a pull request
- Follow TypeScript best practices
- Add error handling for new features
- Update this README for new functionality
- Test on multiple platforms when possible
This example is part of the Tari JavaScript SDK and is licensed under the BSD-3-Clause License.
Happy wallet building! 🚀
For more examples and documentation, visit the Tari JavaScript SDK documentation.