eth::abi¶
Classes¶
| Name | |
|---|---|
| struct | eth::abi::AbiParam |
Types¶
| Name | |
|---|---|
| enum class uint8_t | AbiParamKind { kAddress, kUint, kInt, kBytes32, kBool, kBytes, kString} Identifies one parameter in an event/function signature. |
| using std::variant< codec::Address, intx::uint256, codec::Hash256, bool, codec::ByteBuffer, std::string > | AbiValue A decoded ABI value. Only the types needed for common ERC-20/ERC-721 events are included: address, uint256, bytes32, bool, bytes, string. |
Functions¶
| Name | |
|---|---|
| codec::Hash256 | keccak256(const uint8_t * data, size_t len) Compute Keccak-256 of an arbitrary byte sequence. |
| codec::Hash256 | keccak256(const std::string & text) Compute Keccak-256 of a string (e.g. an event signature). |
| codec::Hash256 | event_signature_hash(const std::string & signature) Compute the event topic[0] hash from a human-readable signature. |
| rlp::Result< AbiValue > | decode_abi_word(const codec::Hash256 & word, AbiParamKind kind) Decode a single 32-byte ABI word from a topic or head slot. |
| rlp::Result< AbiValue > | decode_indexed_param(const codec::Hash256 & topic, const AbiParam & param) Decode an indexed event parameter from a topic hash. |
| rlp::Result< std::vector< AbiValue > > | decode_log_data(const codec::ByteBuffer & data, const std::vector< AbiParam > & params) Decode the ABI-encoded data field of a log entry. |
| rlp::Result< std::vector< AbiValue > > | decode_log(const codec::LogEntry & log, const std::string & signature, const std::vector< AbiParam > & params) Fully decode a log entry given its event descriptor. |
Types Documentation¶
enum AbiParamKind¶
| Enumerator | Value | Description |
|---|---|---|
| kAddress | address | |
| kUint | uint |
|
| kInt | int |
|
| kBytes32 | bytesN where N == 32; also covers bytes1-bytes32 zero-padded | |
| kBool | bool | |
| kBytes | bytes (dynamic) | |
| kString | string (dynamic) |
Identifies one parameter in an event/function signature.
using AbiValue¶
using eth::abi::AbiValue = std::variant<
codec::Address,
intx::uint256,
codec::Hash256,
bool,
codec::ByteBuffer,
std::string
>;
A decoded ABI value. Only the types needed for common ERC-20/ERC-721 events are included: address, uint256, bytes32, bool, bytes, string.
address (20 bytes) uint256 / uint
Functions Documentation¶
function keccak256¶
Compute Keccak-256 of an arbitrary byte sequence.
Parameters:
- data Input bytes.
Return: 32-byte hash.
function keccak256¶
Compute Keccak-256 of a string (e.g. an event signature).
function event_signature_hash¶
Compute the event topic[0] hash from a human-readable signature.
Parameters:
- signature e.g. "Transfer(address,address,uint256)"
Return: 32-byte Keccak-256 of the canonical signature string.
function decode_abi_word¶
Decode a single 32-byte ABI word from a topic or head slot.
Parameters:
- word Exactly 32 bytes (ABI head slot or topic).
- kind Expected parameter type.
Return: Decoded value or error.
- kAddress → reads rightmost 20 bytes
- kUint → reads as big-endian uint256
- kInt → reads as big-endian uint256 (raw bits, no sign extension)
- kBytes32 → returns the 32 bytes directly
- kBool → reads last byte, non-zero = true
function decode_indexed_param¶
rlp::Result< AbiValue > decode_indexed_param(
const codec::Hash256 & topic,
const AbiParam & param
)
Decode an indexed event parameter from a topic hash.
Parameters:
- topic The 32-byte topic value.
- param Parameter descriptor (kind, name).
For value types (address, uint, bool, bytes32) the topic IS the 32-byte ABI-encoded value. Dynamic types (bytes, string) are hashed and cannot be recovered — an empty ByteBuffer / string is returned.
function decode_log_data¶
rlp::Result< std::vector< AbiValue > > decode_log_data(
const codec::ByteBuffer & data,
const std::vector< AbiParam > & params
)
Decode the ABI-encoded data field of a log entry.
Parameters:
- data Raw bytes from LogEntry::data.
- params Ordered list of non-indexed parameters to decode.
Return: Vector of decoded values in the same order as params, or error.
Decodes the non-indexed parameters from the log's data field following the standard ABI head/tail encoding (EIP-838 / Solidity ABI spec).
function decode_log¶
rlp::Result< std::vector< AbiValue > > decode_log(
const codec::LogEntry & log,
const std::string & signature,
const std::vector< AbiParam > & params
)
Fully decode a log entry given its event descriptor.
Parameters:
- log The raw log entry.
- signature Human-readable event signature, e.g. "Transfer(address,address,uint256)".
- params Full ordered parameter list (indexed + non-indexed). topic[0] is implicitly the signature hash and is not listed here.
Return: Decoded values in declaration order (indexed first, then data), or error.
Combines topic decoding (indexed params) and data decoding (non-indexed).
Updated on 2026-04-13 at 23:22:46 -0700