@chainreactionom/nano-mcp-server

1.0.10 • Public • Published

NANO MCP (Model Context Protocol) Server

A high-performance NANO cryptocurrency utility library optimized for AI agent interactions, providing instant finality and fee-less transactions.

Features

  • ✨ 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

Installation

npm install @chainreactionom/nano-mcp-server

Configuration

Environment Variables

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

Programmatic Configuration

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
});

Usage

Basic Operations

// 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');

Send Transaction

// 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 Transactions

// 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
);

Error Handling

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
}

Advanced Features

Balance Validation

const accountInfo = await nano.getAccountInfo(address);
const balance = convert(accountInfo.balance, { from: Unit.raw, to: Unit.NANO });
console.log('Current balance:', balance, 'NANO');

Representative Management

// 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);

Testing

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

Security Best Practices

  1. Never expose private keys in code or version control
  2. Use environment variables for sensitive configuration
  3. Validate all input addresses and amounts
  4. Monitor transaction confirmations
  5. Implement proper error handling
  6. Regular security audits
  7. Keep dependencies updated

Performance Optimization

The library is optimized for:

  • Minimal latency in transaction processing
  • Efficient work generation
  • Optimized RPC calls
  • Reduced network overhead
  • Memory-efficient operations

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see LICENSE file for details

Support

  • Documentation: [Link to docs]
  • Issues: GitHub Issues
  • Community: Discord/Telegram

Version History

  • 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

Package Sidebar

Install

npm i @chainreactionom/nano-mcp-server

Weekly Downloads

47

Version

1.0.10

License

MIT

Unpacked Size

21.8 kB

Total Files

10

Last publish

Collaborators

  • chainreactionom