Skip to main content

Crate txgate_chain

Crate txgate_chain 

Source
Expand description

§txgate-chain

Multi-chain transaction parsing and construction for the TxGate signing service.

§Internal Crate Warning

This crate is an internal implementation detail of txgate.

It is published to crates.io only because Cargo requires all dependencies to be published. The API is unstable and may change without notice between any versions, including patch releases.

Do not depend on this crate directly. Instead:

This crate provides blockchain-specific transaction handling through the Chain trait and chain-specific parser implementations.

§Core Trait

The Chain trait is the foundation for all blockchain parsers:

use txgate_chain::Chain;
use txgate_core::{ParsedTx, TxType, error::ParseError};
use txgate_crypto::CurveType;

struct MyChainParser;

impl Chain for MyChainParser {
    fn id(&self) -> &'static str {
        "my-chain"
    }

    fn parse(&self, raw: &[u8]) -> Result<ParsedTx, ParseError> {
        // Parse chain-specific transaction format
        Ok(ParsedTx {
            chain: "my-chain".to_string(),
            tx_type: TxType::Transfer,
            ..Default::default()
        })
    }

    fn curve(&self) -> CurveType {
        CurveType::Secp256k1
    }
}

§Modules (planned)

  • evm - Ethereum and EVM-compatible chains (Polygon, Arbitrum, etc.)
  • solana - Solana transaction parsing
  • bitcoin - Bitcoin transaction handling
  • substrate - Substrate-based chains (Polkadot, etc.)
  • cosmos - Cosmos SDK chains

§Features

  • Transaction parsing and validation
  • Human-readable transaction decoding
  • ABI/IDL decoding for smart contract interactions
  • Gas estimation helpers
  • Chain-specific address validation

§Supported Chains (planned)

  • Ethereum Mainnet and testnets
  • Polygon, Arbitrum, Optimism, Base
  • Solana Mainnet and Devnet
  • Bitcoin Mainnet and Testnet

§Crate Features

  • mock - Enable MockChain for use in other crates’ tests

§Chain Registry

The ChainRegistry provides runtime lookup of chain parsers:

use txgate_chain::ChainRegistry;

let registry = ChainRegistry::new();

// List all supported chains
for chain_id in registry.supported_chains() {
    println!("Supported: {chain_id}");
}

// Look up a specific chain
if let Some(parser) = registry.get("ethereum") {
    println!("Found parser for: {}", parser.id());
}

Re-exports§

pub use chain::Chain;
pub use bitcoin::BitcoinParser;
pub use ethereum::EthereumParser;
pub use solana::SolanaParser;
pub use registry::ChainRegistry;
pub use tokens::RiskLevel;
pub use tokens::TokenInfo;
pub use tokens::TokenRegistry;
pub use erc20::parse_erc20_call;
pub use erc20::Erc20Call;

Modules§

bitcoin
Bitcoin transaction parser.
chain
Chain trait for blockchain transaction parsers.
erc20
ERC-20 calldata parsing module.
ethereum
Ethereum transaction parser implementation.
registry
Chain registry for runtime chain lookup.
rlp
RLP decoding utilities for Ethereum transaction parsing.
solana
Solana transaction parser.
tokens
Token registry for ERC-20 tokens.

Enums§

CurveType
Elliptic curve types supported by TxGate.