| Crates.io | costx |
| lib.rs | costx |
| version | 0.1.0 |
| created_at | 2025-07-09 12:45:19.634325+00 |
| updated_at | 2025-07-09 12:45:19.634325+00 |
| description | Blockchain transaction analysis tools for EVM chains and Solana |
| homepage | |
| repository | https://github.com/mayan-finance/costx |
| max_upload_size | |
| id | 1744896 |
| size | 259,271 |
Costx is a Rust library for analyzing blockchain transactions across multiple chains. It supports both EVM-based chains (Ethereum, Polygon, Arbitrum, etc.) and Solana.
Add to your Cargo.toml:
[dependencies]
costx = "0.1.0"
clap = { version = "4.0", features = ["derive"] }
tokio = { version = "1.0", features = ["full"] }
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(())
}
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(())
}
The library also comes with a built-in REST API server:
# Run with default settings
cargo run
# Run with custom port
cargo run -- --port 8080
# Run with custom RPC URLs
cargo run -- --eth-rpc-url https://custom-eth-rpc.com --solana-rpc-url https://custom-solana-rpc.com
All configuration options can be set via environment variables:
export PORT=8080
export ETH_RPC_URL="https://custom-eth-rpc.com"
export SOLANA_RPC_URL="https://custom-solana-rpc.com"
# ... and more
GET /evm/chains - Get supported EVM chainsGET /evm/analyze/{chain}/{tx_hash} - Analyze transactionPOST /evm/transaction - Analyze transaction (JSON body)GET /solana/networks - Get supported Solana networksGET /solana/analyze/{network}/{signature} - Analyze transactionPOST /solana/transaction - Analyze transaction (JSON body)Run the usage example:
cargo run --example usage
EVMConfig)--base-rpc-url / BASE_RPC_URL--arbitrum-rpc-url / ARBITRUM_RPC_URL--avax-rpc-url / AVAX_RPC_URL--polygon-rpc-url / POLYGON_RPC_URL--optimism-rpc-url / OPTIMISM_RPC_URL--unichain-rpc-url / UNICHAIN_RPC_URL--eth-rpc-url / ETH_RPC_URLSolanaConfig)--solana-rpc-url / SOLANA_RPC_URLMIT