Skip to main content

Module abi

Module abi 

Source
Expand description

ABI related helper functions.

Re-exportsΒ§

use alloy_chains::Chain; πŸ”’
use alloy_dyn_abi::DecodedEvent; πŸ”’
use alloy_dyn_abi::DynSolType; πŸ”’
use alloy_dyn_abi::DynSolValue; πŸ”’
use alloy_dyn_abi::FunctionExt; πŸ”’
use alloy_dyn_abi::JsonAbiExt; πŸ”’
use alloy_dyn_abi::Specifier; πŸ”’
use alloy_json_abi::Error; πŸ”’
use alloy_json_abi::Event; πŸ”’
use alloy_json_abi::Function; πŸ”’
use alloy_json_abi::Param; πŸ”’
use alloy_primitives::Address; πŸ”’
use alloy_primitives::LogData; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_primitives::hex; πŸ”’
use eyre::Context; πŸ”’
use eyre::ContextCompat; πŸ”’
use eyre::Result; πŸ”’
use foundry_block_explorers::Client; πŸ”’
use foundry_block_explorers::contract::ContractMetadata; πŸ”’
use foundry_block_explorers::errors::EtherscanError; πŸ”’
use std::pin::Pin; πŸ”’

FunctionsΒ§

abi_decode_calldata
Decodes the calldata of the function
abi_decode_event_data
ABI-decodes the non-indexed parameters (the log data) of an event.
coerce_value
Helper function to coerce a value to a [DynSolValue] given a type string
encode_args
encode_function_args
Given a function and a vector of string arguments, it proceeds to convert the args to alloy [DynSolValue]s and then ABI encode them, prefixes the encoded data with the function selector.
encode_function_args_packed
Given a function and a vector of string arguments, it proceeds to convert the args to alloy [DynSolValue]s and encode them using the packed encoding.
encode_function_args_raw
Given a function and a vector of string arguments, it proceeds to convert the args to alloy [DynSolValue]s and then ABI encode them. Doesn’t prefix the function selector.
find_source
If the code at address is a proxy, recurse until we find the implementation.
get_error
Given an error signature string, it tries to parse it as a Error
get_event
Given an event signature string, it tries to parse it as a Event
get_func
Given a function signature string, it tries to parse it as a Function
get_func_etherscan
Given a function name, address, and args, tries to parse it as a Function by fetching the abi from etherscan. If the address is a proxy, fetches the ABI of the implementation contract.
get_indexed_event
Given an event without indexed parameters and a rawlog, it tries to return the event with the proper indexed parameters. Otherwise, it returns the original event.
reconstruct_event_params
Restore the order of the params of a decoded event, as Alloy returns the indexed and unindexed params separately.