gleeth/ethereum/abi/decode
Types
Result of decoding calldata against an ABI.
pub type DecodedCalldata {
DecodedCalldata(
function_name: String,
arguments: List(types.AbiValue),
)
}
Constructors
-
DecodedCalldata( function_name: String, arguments: List(types.AbiValue), )
Result of decoding a revert reason.
pub type DecodedRevert {
RevertString(String)
RevertPanic(Int)
RevertCustomError(
name: String,
arguments: List(types.AbiValue),
)
RevertUnknown(BitArray)
}
Constructors
-
RevertString(String)Standard Error(string) revert
-
RevertPanic(Int)Standard Panic(uint256) revert
-
RevertCustomError(name: String, arguments: List(types.AbiValue))Custom error decoded against an ABI
-
RevertUnknown(BitArray)Unknown selector, raw data preserved
Values
pub fn decode(
type_list: List(types.AbiType),
data: BitArray,
) -> Result(List(types.AbiValue), types.AbiError)
Decode ABI-encoded data given a list of expected types. This is the top-level decoder for function return values or event data.
pub fn decode_calldata(
calldata_hex: String,
entries: List(json.AbiEntry),
) -> Result(DecodedCalldata, types.AbiError)
Decode calldata by matching the 4-byte selector against parsed ABI entries. Returns the function name and decoded argument values.
pub fn decode_function_input(
signature: String,
calldata_hex: String,
) -> Result(List(types.AbiValue), types.AbiError)
Decode calldata given a function signature string like “transfer(address,uint256)”. Computes the selector from the signature and decodes the parameters.
pub fn decode_function_output(
output_types_sig: String,
result_hex: String,
) -> Result(List(types.AbiValue), types.AbiError)
Decode the return value of a function given its output type signature. For example: decode_function_output(“(uint256)”, result_hex)
pub fn decode_revert(
revert_hex: String,
) -> Result(DecodedRevert, types.AbiError)
Decode revert data. Handles standard Error(string) with selector 0x08c379a0, Panic(uint256) with selector 0x4e487b71, and custom errors if an ABI is provided.
pub fn decode_revert_with_abi(
revert_hex: String,
entries: List(json.AbiEntry),
) -> Result(DecodedRevert, types.AbiError)
Decode revert data, matching custom errors against provided ABI entries.
pub fn decode_single(
type_: types.AbiType,
data: BitArray,
) -> Result(types.AbiValue, types.AbiError)
Decode a single value of a known type from ABI-encoded data.