Scrutiny Chain Blockchain Core
Core blockchain functionality and traits for the Scrutiny Chain blockchain security analysis platform.
Overview
The scrutiny_chain_blockchain_core crate provides the foundational abstractions and models for interacting with blockchain data in the Scrutiny Chain ecosystem. It defines key interfaces that other crates implement to ensure consistent interaction with various blockchain data sources.
Features
Blockchain Data Provider
The core of this crate is the BlockchainDataProvider trait, which defines the standard interface for accessing blockchain data:
use BlockchainDataProvider;
use ;
// Example usage with any provider implementing the trait
async
Blockchain Models
The crate defines standard models for blockchain data:
Transaction
use Transaction;
use ;
// Create a new transaction
let tx = new;
// Calculate total cost
let cost = tx.total_cost; // value + (gas_price * gas_limit)
// Check if it's a contract creation
let is_creation = tx.is_contract_creation;
Smart Contract
use SmartContract;
use Address;
// Create a new smart contract
let contract = new;
// Get contract details
let bytecode_size = contract.bytecode_size;
let age = contract.age_in_seconds;
Security Analysis
use SecurityAnalysis;
use RiskLevel;
use HashMap;
// Create a security analysis result
let analysis = SecurityAnalysis ;
Blockchain Errors
The crate defines specific error types for blockchain operations:
use BlockchainError;
// Handle specific blockchain errors
match result
Requirements
- Rust 2021 edition or later
- The
scrutiny_chain_commoncrate from the Scrutiny Chain workspace
Usage
Add this crate as a dependency in your Cargo.toml:
[]
= { = "../scrutiny_chain_blockchain-core" }
Development
Building
Testing
Watch Mode Testing
Documentation
Generate and view the documentation:
Implementation Example
Here's a simplified example of implementing the BlockchainDataProvider trait:
use ;
use ;
use ;
use Result;
use async_trait;
use HashMap;