apex-sdk
A unified Rust SDK for seamless blockchain development across EVM and Substrate ecosystems.
Overview
Apex SDK is a comprehensive Rust library that provides a unified interface for interacting with multiple blockchain ecosystems. Whether you're building applications for Ethereum, Polkadot, Kusama, or other EVM/Substrate chains, Apex SDK offers type-safe, async-first APIs that abstract away the complexity of multi-chain development.
Key Features
- Multi-Chain Support: EVM (Ethereum, Polygon, BSC) and Substrate (Polkadot, Kusama) chains
- Type Safety: Compile-time guarantees with Rust's type system
- Async-First: Built with
async/awaitfor high-performance applications - Cross-Chain: Unified APIs for seamless cross-chain interactions
- Modular Design: Use only what you need with feature flags
- Testing: Comprehensive test coverage with integration tests
- Documentation: Extensive documentation with examples
Installation
Add this to your Cargo.toml:
[]
= "0.1.3"
= { = "1.0", = ["full"] }
Quick Start
Unified Multi-Chain Interface
use ;
async
Cross-Chain Transfers
use ;
// Bridge assets between EVM and Substrate chains
let bridge = new;
let tx_hash = bridge
.transfer
.await?;
println!;
Smart Contract Interaction
use ;
// EVM smart contracts
let eth_contract = new;
let result = eth_contract
.method?
.call
.await?;
// Substrate ink! contracts
let ink_contract = new
.at_address;
let result = ink_contract
.call
.dry_run
.await?;
Architecture
Apex SDK is built with a modular architecture:
apex-sdk/
├── apex-sdk-core/ # Core traits and interfaces
├── apex-sdk-types/ # Shared types and structures
├── apex-sdk-evm/ # EVM blockchain adapter
├── apex-sdk-substrate/ # Substrate blockchain adapter
└── examples/ # Usage examples
Core Components
apex-sdk-core: Foundational traits and error handlingapex-sdk-types: Common types for cross-chain compatibilityapex-sdk-evm: Ethereum and EVM-compatible chain supportapex-sdk-substrate: Polkadot and Substrate chain support
Features
EVM Ecosystem Support
- Chains: Ethereum, Polygon, BSC, Arbitrum, Optimism, Avalanche
- Protocols: ERC-20, ERC-721, ERC-1155 tokens
- DeFi: Uniswap, SushiSwap, Compound integration
- Layer 2: Optimistic Rollups, zk-Rollups support
use EvmAdapter;
// Multi-chain EVM support
let ethereum = new;
let polygon = new;
let bsc = new;
// DeFi operations
let uniswap = ethereum.defi.uniswap_v3;
let swap_tx = uniswap
.swap
.slippage // 0.5%
.execute
.await?;
Substrate Ecosystem Support
- Chains: Polkadot, Kusama, Westend, custom parachains
- Features: Staking, governance, treasury, identity
- Contracts: ink! smart contract deployment and interaction
- XCM: Cross-chain messaging and asset transfers
use ;
// Multi-chain Substrate support
let polkadot = polkadot.await?;
let kusama = kusama.await?;
// Cross-chain messaging
let xcm = new;
let transfer_tx = xcm
.transfer_to_parachain // Acala
.await?;
// Governance participation
let gov_tx = polkadot
.governance
.vote
.await?;
Unified Wallet Management
use ;
// Generate new wallet
let mnemonic = generate;
let wallet = from_mnemonic?;
// Works with both ecosystems
let eth_signer = wallet.evm_signer;
let substrate_signer = wallet.substrate_signer;
// Multi-sig support
let multisig = multisig?;
Advanced Usage
Connection Pooling
use ;
let pool_config = PoolConfig ;
let eth_pool = with_pool.await?;
Caching and Performance
use ;
let cache_config = CacheConfig ;
let adapter = new
.with_cache
.with_metrics;
Event Monitoring
use ;
// EVM event monitoring
let filter = new
.address
.topic;
let mut stream = eth_adapter.subscribe_events.await?;
while let Some = stream.next.await
// Substrate event monitoring
let mut substrate_events = dot_adapter.subscribe_events.await?;
while let Some = substrate_events.next.await
Testing
Running Tests
# Unit tests
# Integration tests (requires network access)
# All tests
Test Configuration
# Environment variables for testing
Examples
Comprehensive examples are available in the examples/ directory:
- Account Manager - Multi-chain account management
- Price Oracle - Cross-chain price aggregation
- Contract Orchestration - Smart contract deployment
- Parachain Assets - Parachain asset management
Configuration
Feature Flags
[]
= { = "0.1.3", = ["full"] }
# Or choose specific features
= {
version = "0.1.3",
= [
"evm", # EVM support
"substrate", # Substrate support
"contracts", # Smart contract support
"xcm", # Cross-chain messaging
"metrics", # Metrics collection
"cache", # Caching layer
]
}
Available features:
evm- EVM blockchain supportsubstrate- Substrate blockchain supportcontracts- Smart contract interactionxcm- Cross-chain messagingmetrics- Prometheus metricscache- Response cachingfull- All features enabled
Environment Configuration
# Chain endpoints
ETHEREUM_RPC_URL="https://eth.llamarpc.com"
POLYGON_RPC_URL="https://polygon-rpc.com"
POLKADOT_RPC_URL="wss://rpc.polkadot.io"
KUSAMA_RPC_URL="wss://kusama-rpc.polkadot.io"
# API keys
INFURA_API_KEY="your-infura-key"
ALCHEMY_API_KEY="your-alchemy-key"
# Wallet configuration (for development only)
PRIVATE_KEY="0x..."
MNEMONIC="word1 word2 ... word12"
# Performance tuning
MAX_CONNECTIONS="10"
REQUEST_TIMEOUT="30"
CACHE_TTL="300"
Monitoring and Observability
Metrics
Built-in Prometheus metrics for monitoring:
use MetricsConfig;
let metrics = MetricsConfig ;
let adapter = new
.with_metrics;
Available metrics:
apex_rpc_calls_total- Total RPC calls madeapex_rpc_call_duration_seconds- RPC call latencyapex_cache_hits_total- Cache hitsapex_cache_misses_total- Cache missesapex_transactions_total- Transactions submittedapex_transaction_confirmations- Transaction confirmation times
Logging
use ;
use tracing_subscriber;
// Initialize logging
init;
// Logging is automatically integrated
let result = adapter.get_balance.await?;
info!;
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
# Clone repository
# Install dependencies
# Run tests
# Format code
# Lint code
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Acknowledgments
- Substrate - Blockchain framework for Polkadot ecosystem
- ethers-rs - Ethereum library for Rust
- subxt - Substrate RPC client
- tokio - Asynchronous runtime for Rust
Support
- Documentation: docs.rs/apex-sdk
- GitHub Issues: Report bugs
- Discussions: GitHub Discussions
- Examples: examples/
Roadmap
- v0.2.0: Enhanced XCM support, more parachain integrations
- v0.3.0: Zero-knowledge proof integration
- v0.4.0: Multi-signature wallet improvements
- v0.5.0: GraphQL API support
- v1.0.0: Stable API, production ready