Skip to main content

infer_chain_from_hash

Function infer_chain_from_hash 

Source
pub fn infer_chain_from_hash(hash: &str) -> Option<&'static str>
Expand description

Infers the blockchain from a transaction hash format.

Returns Some(chain_name) if the hash format is unambiguous, or None if the format is not recognized.

§Supported Formats

  • EVM (ethereum): 0x prefix + 64 hex chars (66 total)
  • Tron: 64 hex chars (no prefix)
  • Solana: Base58, 80-90 chars, decodes to 64 bytes

§Examples

use scope::chains::infer_chain_from_hash;

// EVM hash
let evm_hash = "0xabc123def456789012345678901234567890123456789012345678901234abcd";
assert_eq!(infer_chain_from_hash(evm_hash), Some("ethereum"));

// Tron hash (64 hex chars, no 0x prefix)
let tron_hash = "abc123def456789012345678901234567890123456789012345678901234abcd";
assert_eq!(infer_chain_from_hash(tron_hash), Some("tron"));