A high-performance NANO cryptocurrency utility library optimized for AI agent interactions, providing instant finality and fee-less transactions.
- ✨ Instant finality for quick agent decision making
- 💸 Fee-less transactions for efficient resource allocation
- 📈 Scalable architecture for large agent networks
- ✅ Deterministic confirmation for reliable agent operations
- 🔒 Secure key management and validation
- 🚀 High-performance RPC operations
- 🔄 Automated work generation
- 📡 Real-time transaction monitoring
npm install @chainreactionom/nano-mcp-server
Create a .env
file in your project root:
# Required Parameters
NANO_RPC_URL=https://rpc.nano.to/ # Required: URL of the NANO RPC server
NANO_RPC_KEY=your-rpc-key-here # Required: Get from https://rpc.nano.to/
NANO_GPU_KEY=your-gpu-key-here # Required: For work generation
# Optional Parameters
# Choose your representative from https://nanexplorer.com/nano/representatives
NANO_DEFAULT_REPRESENTATIVE=nano_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4
import { NanoMCP } from '@chainreactionom/nano-mcp-server';
// Initialize with custom configuration
const mcp = await NanoMCP.initialize({
rpcUrl: 'https://rpc.nano.to/',
rpcKey: 'your-rpc-key',
gpuKey: 'your-gpu-key',
defaultRepresentative: 'your-representative-address' // Optional
});
// Create a new instance
const nano = new NanoTransactions();
// Get account information
const accountInfo = await nano.getAccountInfo('nano_address');
// Get pending blocks
const pending = await nano.getPendingBlocks('nano_address');
// Generate work for a block
const work = await nano.generateWork('block_hash');
// First get account info
const accountInfo = await nano.getAccountInfo(fromAddress);
// Create and process send block
const result = await nano.createSendBlock(
fromAddress,
privateKey,
toAddress,
'0.001', // Amount in NANO
accountInfo
);
console.log('Send transaction result:', result);
// Result includes:
// - hash: Block hash
// - block: Block details
// - confirmationTime: "< 1 second"
// - fee: "0"
// Receive all pending blocks
const result = await nano.receiveAllPending(address, privateKey);
// For new accounts, create open block
const openResult = await nano.createOpenBlock(
address,
privateKey,
sourceBlock,
sourceAmount
);
The library provides detailed error messages and validation:
try {
const result = await nano.createSendBlock(/* ... */);
} catch (error) {
console.error('Transaction failed:', error.message);
// Detailed error information:
// - Invalid addresses
// - Insufficient balance
// - RPC errors
// - Work generation failures
}
const accountInfo = await nano.getAccountInfo(address);
const balance = convert(accountInfo.balance, { from: Unit.raw, to: Unit.NANO });
console.log('Current balance:', balance, 'NANO');
// Get current representative
const info = await nano.getAccountInfo(address);
console.log('Current representative:', info.representative);
// Change representative (requires private key)
const result = await nano.changeRepresentative(address, privateKey, newRepresentative);
The library includes comprehensive test suites:
# Run all tests
npm test
# Run specific test suites
npm test -- --testPathPattern=rpc.test.ts
npm test -- --testPathPattern=mcp.test.ts
Test coverage includes:
- RPC operations
- Transaction creation and processing
- Error handling
- Configuration validation
- Work generation
- Account management
- Balance operations
- Representative management
- Never expose private keys in code or version control
- Use environment variables for sensitive configuration
- Validate all input addresses and amounts
- Monitor transaction confirmations
- Implement proper error handling
- Regular security audits
- Keep dependencies updated
The library is optimized for:
- Minimal latency in transaction processing
- Efficient work generation
- Optimized RPC calls
- Reduced network overhead
- Memory-efficient operations
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details
- Documentation: [Link to docs]
- Issues: GitHub Issues
- Community: Discord/Telegram
- 1.0.9: Added comprehensive testing and enhanced error handling
- 1.0.8: Improved representative management
- 1.0.7: Enhanced transaction validation
- 1.0.6: Added work generation optimization
- 1.0.5: Initial release