This document explains how to generate and view the comprehensive RDoc documentation for the MixinBot gem.
RDoc is Ruby's built-in documentation tool. To generate documentation:
# Generate HTML documentation
rdoc
# Generate documentation with custom options
rdoc --main README.md --title "MixinBot - Ruby SDK for Mixin Network"The documentation will be generated in the doc/ directory.
YARD provides enhanced documentation features:
# Install YARD if not already installed
gem install yard
# Generate YARD documentation
yard doc
# Start YARD server to browse documentation
yard serverThen visit http://localhost:8808 in your browser.
The MixinBot gem documentation is organized into the following sections:
The root module containing:
- Configuration management
- Global API instance
- Error definitions
- Utility access
Main interface for all Mixin Network operations:
- User and bot profile management
- Asset operations
- Transfers and payments
- Messaging via Blaze
- Multisig operations
- NFT/collectible operations
Credential and settings management:
- Application credentials
- Key management
- Host configuration
HTTP client for API requests:
- Request/response handling
- Authentication
- Error handling
UUID format conversions between:
- Standard UUID format (with dashes)
- Packed binary format
- Hex format
Mixin Network address handling:
- Address encoding/decoding
- Multi-signature addresses
- Main network addresses
Invoice creation and parsing:
- Payment requests
- QR code generation
- Invoice validation
NFT memo handling:
- NFT minting
- Token identification
- Metadata encoding
Transaction encoding/decoding:
- Safe API transactions
- Legacy transactions
- Input/output management
Cryptographic operations:
- JWT token generation
- Key generation (Ed25519, RSA)
- Transaction signing
- PIN encryption
- UUID generation
Data encoding utilities:
- Integer encoding
- Transaction encoding
- Binary packing
Data decoding utilities:
- Integer decoding
- Transaction decoding
- Binary unpacking
Address utilities:
- Address validation
- Key derivation
- Ghost key generation
Mixin Virtual Machine integration:
Cross-chain bridge operations
HTTP client for MVM services
NFT operations on MVM
Contract registry operations
Blockchain explorer interface
The API class includes the following modules, each handling specific API endpoints:
MixinBot::API::Me- Bot profile operationsMixinBot::API::User- User lookup and searchMixinBot::API::Auth- Authentication operations
MixinBot::API::Asset- Asset informationMixinBot::API::Snapshot- Transaction historyMixinBot::API::Output- UTXO operations
MixinBot::API::Transfer- Safe API transfersMixinBot::API::Payment- Payment operationsMixinBot::API::Transaction- Transaction managementMixinBot::API::LegacyTransfer- Legacy transfers
MixinBot::API::Blaze- WebSocket messagingMixinBot::API::Message- Message operationsMixinBot::API::EncryptedMessage- Encrypted messagesMixinBot::API::Conversation- Conversation management
MixinBot::API::Multisig- Multisig operationsMixinBot::API::LegacyMultisig- Legacy multisig
MixinBot::API::Inscription- Inscription operationsMixinBot::API::LegacyCollectible- Legacy collectibles
MixinBot::API::Pin- PIN managementMixinBot::API::Withdraw- Withdrawal operationsMixinBot::API::Attachment- File attachmentsMixinBot::API::Address- Address operationsMixinBot::API::Rpc- RPC operationsMixinBot::API::Tip- TIP signing
The documentation includes extensive examples throughout. Here are some key examples:
# Configure bot
MixinBot.configure do
app_id = 'your-app-id'
session_id = 'your-session-id'
session_private_key = 'your-private-key'
server_public_key = 'server-public-key'
end
# Get bot profile
profile = MixinBot.api.me
puts profile['full_name']
# List assets
assets = MixinBot.api.assets
assets.each do |asset|
puts "#{asset['symbol']}: #{asset['balance']}"
end# Simple transfer
result = MixinBot.api.create_transfer(
members: 'recipient-user-id',
asset_id: 'asset-uuid',
amount: '0.01',
memo: 'Payment'
)
# Multisig transfer (2-of-3)
result = MixinBot.api.create_transfer(
members: ['user1', 'user2', 'user3'],
threshold: 2,
asset_id: 'asset-uuid',
amount: '0.01'
)# Connect to Blaze
EM.run {
MixinBot.api.start_blaze_connect do
def on_message(blaze, event)
raw = JSON.parse(event.data)
# Process message
end
end
}The documentation describes all custom error classes:
MixinBot::Error- Base errorMixinBot::HttpError- HTTP errorsMixinBot::ResponseError- API response errorsMixinBot::UnauthorizedError- Authentication failuresMixinBot::InsufficientBalanceError- Balance issues- And more...
Example:
begin
MixinBot.api.create_transfer(...)
rescue MixinBot::InsufficientBalanceError => e
puts "Insufficient balance: #{e.message}"
rescue MixinBot::ResponseError => e
puts "API error: #{e.message}"
endAfter generation, open the documentation:
# Open in default browser
open doc/index.html # macOS
xdg-open doc/index.html # Linux
start doc/index.html # Windows# Start server
yard server
# Visit http://localhost:8808All documentation follows Ruby community standards:
- RDoc Format: Uses standard RDoc markup
- Method Documentation: All public methods are documented with:
- Description
- Parameters with types
- Return values with types
- Examples
- Related links
- Module Documentation: Comprehensive module/class overviews
- Examples: Real-world usage examples throughout
- Cross-references: Links between related classes and methods
When adding new features or modifying existing code:
- Document all public methods
- Include parameter types and descriptions
- Provide usage examples
- Update module overviews when needed
- Add cross-references to related functionality
- Follow existing documentation style