Blockchain Runtime
Blockchain-agnostic runtime abstraction for dynamic analysis, testing, and simulation.
Features
- Blockchain-Agnostic: Unified interface for any blockchain
- Dynamic Analysis: Execute smart contracts in isolated environments
- Testing: Spin up test networks for contract testing
- Simulation: Simulate transactions and monitor behavior
- Metrics: Track gas, compute units, state changes
- Event Monitoring: Capture blockchain events and logs
- Async-First: Non-blocking operations
Installation
[]
= "0.1"
# With tracing support
= { = "0.1", = ["tracing"] }
Quick Start
use ;
use HashMap;
Use Cases
Smart Contract Testing
// Create test environment
let config = RuntimeConfig ;
let env = runtime.create_environment.await?;
// Deploy contract
let address = runtime.deploy_contract.await?;
// Call contract function
let result = runtime.call_function.await?;
// Check results
assert!;
Gas Estimation
let result = runtime.execute.await?;
if let Some = result.metrics.get
State Inspection
let result = runtime.execute.await?;
for change in result.state_changes
Event Monitoring
let events = runtime.monitor.await?;
for event in events
Runtime Types
- Docker: Containerized blockchain nodes
- LocalProcess: Native process (e.g., Ganache, Hardhat)
- CloudInstance: Cloud-hosted test networks
- InMemory: In-memory simulation
Network Modes
- Local: Local test network (no real funds)
- Testnet: Public test network
- MainnetFork: Mainnet fork for realistic testing
Supported Capabilities
let caps = runtime.capabilities;
if caps.supports_contract_deployment
if caps.supports_gas_estimation
if caps.supports_time_travel
Configuration
use RuntimeConfig;
use HashMap;
let mut config = default;
// Set limits
config.timeout_seconds = 600;
config.memory_limit_mb = 2048;
// Network mode
config.network_mode = Testnet;
// Blockchain-specific config
config.blockchain_config.insert;
Metrics
Track blockchain-specific metrics:
let metrics = runtime.metrics_definition;
for metric in metrics
// Common metrics:
// - gas_used: Gas consumed (units)
// - compute_units: Compute units (Solana)
// - storage_delta: Storage change (bytes)
// - execution_time: Time taken (ms)
Origin
Extracted from Red Asgard, a security platform where it provides runtime execution environments for dynamic smart contract analysis across multiple blockchains.
License
Licensed under MIT License. See LICENSE-MIT for details.
Contributing
Contributions welcome! Areas of interest:
- Additional blockchain implementations
- Performance optimizations
- Testing utilities
- Documentation improvements
Contact
- Author: Red Asgard
- Email: hello@redasgard.com
- GitHub: https://github.com/redasgard