Crate costx

Source
Expand description

Costx is a library for analyzing blockchain transactions across multiple chains. It supports both EVM-based chains (Ethereum, Polygon, Arbitrum, etc.) and Solana.

§Examples

§EVM Transaction Analysis

use costx::evm::{EVMChainManager, EVMConfig};
use clap::Parser;
 
#[derive(Parser)]
struct Config {
    #[command(flatten)]
    evm: EVMConfig,
}
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::parse();
    let manager = EVMChainManager::new(&config.evm);
     
    let analysis = manager.analyze_transaction("ethereum", "0x...").await?;
    println!("Transaction fee: {:?}", analysis.transaction_fee);
     
    Ok(())
}

§Solana Transaction Analysis

use costx::solana::{SolanaChainManager, SolanaConfig};
use clap::Parser;
 
#[derive(Parser)]
struct Config {
    #[command(flatten)]
    solana: SolanaConfig,
}
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::parse();
    let manager = SolanaChainManager::new(&config.solana);
     
    let analysis = manager.analyze_transaction("mainnet", "signature...").await?;
    println!("Transaction fee: {:?}", analysis.transaction_fee);
     
    Ok(())
}

Re-exports§

pub use evm::ChainConfig;
pub use evm::EVMChainManager;
pub use evm::TransactionAnalysis;
pub use evm::ERC20Transfer;
pub use evm::EVMConfig;
pub use solana::SolanaChainConfig;
pub use solana::SolanaChainManager;
pub use solana::SolanaTransactionAnalysis;
pub use solana::SolBalanceChange;
pub use solana::TokenBalanceChange;
pub use solana::SolanaConfig;

Modules§

evm
solana

Type Aliases§

Result
Result<T, Error>