OneMoney Rust SDK
Official Rust SDK for the OneMoney L1 blockchain REST API.
Features
- Async/await support - Built with Tokio for high-performance async operations
- Cryptographic utilities - ECDSA signing, address derivation, and message verification
- Type-safe API - Strongly typed requests and responses with comprehensive error handling
- Modular design - Organized by functionality (accounts, tokens, transactions, etc.)
- Network support - Mainnet and testnet configurations
- Extensible - Hook system for middleware and custom logging
- Well documented - Comprehensive API documentation and examples
- Thoroughly tested - 398+ tests with 80%+ code coverage and continuous integration
- Production ready - Comprehensive error handling, retry logic, and security audits
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["macros", "rt-multi-thread"] }
Quick Start
use ;
use ;
use FromStr;
async
Core Functionality
Client Configuration
use ;
use Duration;
// Basic clients
let client = mainnet; // Mainnet
let client = testnet; // Testnet
// Custom configuration
let client = new
.netwok
.timeout
.build?;
Account Operations
// Get account nonce
let nonce = client.get_account_nonce.await?;
// Get token account balance
let token_account = client.get_associated_token_account.await?;
println!;
// List all token accounts for an address
let = client.list_token_accounts.await?;
// Derive token account address
let token_account_addr = client.derive_token_account_address;
Token Operations
use ;
// Mint tokens
let mint_payload = TokenMintPayload ;
let result = client.mint_token.await?;
Transaction Operations
use PaymentPayload;
// Send a payment
let payment = PaymentPayload ;
let result = client.send_payment.await?;
println!;
// Get transaction details
let tx = client.get_transaction_by_hash.await?;
println!;
// Wait for confirmation
let confirmed_tx = client.wait_for_transaction.await?;
Blockchain State
// Get latest checkpoint number (for transaction construction)
let checkpoint_info = client.get_checkpoint_number.await?;
// Get chain information
let chain = client.get_chain_info.await?;
println!;
// Get network statistics
let stats = client.get_network_stats.await?;
println!;
Cryptographic Utilities
use crypto;
// Derive address from private key
let address = private_key_to_address?;
// Sign a message
let signature = sign_message?;
// Verify signature
let is_valid = verify_signature?;
Error Handling
The SDK provides comprehensive error handling:
use ;
match client.get_account_nonce.await
Examples
Run the included examples:
# Transaction management example
# Network configuration examples
# Token operations example
# Account management example
API Reference
The SDK is organized into several modules:
accounts- Account queries, nonce management, token account operationstokens- Token minting, burning, authority management, pause/blacklist/whitelist controlstransactions- Payment sending, transaction queries, fee estimationchains- Chain information and network detailscheckpoints- Checkpoint queries and blockchain statecrypto- Cryptographic utilities for signing and verification
Configuration
Environment Variables
ONEMONEY_API_URL- Override the default API endpointONEMONEY_TIMEOUT- Set request timeout in secondsONEMONEY_LOG_LEVEL- Set logging level (trace, debug, info, warn, error)
Network Endpoints
- Mainnet:
https://api.1money.network - Testnet:
https://api.testnet.1money.network
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run the test suite:
cargo test - Submit a pull request
Testing
# Run all tests
# Run tests with output
# Run specific test module
# Run tests with coverage (requires cargo-llvm-cov)
# Run integration tests
# Run unit tests only
License
This project is licensed under the Apache License, Version 2.0.
See LICENSE for details or visit http://www.apache.org/licenses/LICENSE-2.0.
Support
Built by the OneMoney team.