pub fn contract_info(args: ContractInfoArgs<'_>) -> ContractExpand description
Extracts information about a smart contract from its EVM bytecode.
§Parameters
args: AContractInfoArgsinstance specifying what data to extract from the provided bytecode. Use the builder-style methods onContractInfoArgs(e.g.,.with_selectors(),.with_arguments()) to enable specific analyses.
§Returns
Returns a Contract object containing the requested smart contract information. The
Contract struct wraps optional fields depending on the configuration provided in args.
§Examples
use evmole::{ContractInfoArgs, StateMutability, contract_info};
use alloy_primitives::hex;
let code = hex::decode("6080604052348015600e575f80fd5b50600436106030575f3560e01c80632125b65b146034578063b69ef8a8146044575b5f80fd5b6044603f3660046046565b505050565b005b5f805f606084860312156057575f80fd5b833563ffffffff811681146069575f80fd5b925060208401356001600160a01b03811681146083575f80fd5b915060408401356001600160e01b0381168114609d575f80fd5b80915050925092509256").unwrap();
// Extract function selectors and their state mutability
let args = ContractInfoArgs::new(&code)
.with_selectors()
.with_state_mutability();
let info = contract_info(args);
let fns = info.functions.unwrap();
assert_eq!(fns.len(), 2);
assert_eq!(fns[0].selector, [0x21, 0x25, 0xb6, 0x5b]);
assert_eq!(fns[0].state_mutability, Some(StateMutability::Pure));