Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EthereumLog ¶
type EthereumLog struct { Event *abi.Event `json:"-"` // ABI definition of the log's event. Abi string `json:"abi"` // ABI string of the event. SignatureHex common.Hash `json:"signature_hex"` // Hex-encoded signature of the event. Signature string `json:"signature"` // Signature of the event. Type string `json:"type"` // Type of the event Name string `json:"name"` // Name of the event. Data map[string]any `json:"data"` // Decoded event data. Topics []EthereumTopic `json:"topics"` // Decoded topics of the event. }
EthereumLog encapsulates a decoded Ethereum event log. It includes the event's details such as its name, signature, the contract that emitted the event, and the decoded data and topics.
func DecodeEthereumLog ¶
func DecodeEthereumLog(log types.Log, aData string) (*EthereumLog, error)
DecodeEthereumLog decodes an Ethereum event log using the provided ABI data. It returns an EthereumLog instance containing the decoded event name, data, and topics.
Example:
log := &types.Log{} abiData := "<ABI JSON string>" decodedLog, err := DecodeEthereumLog(log, abiData) if err != nil { log.Fatalf("Failed to decode log: %v", err) }
func DecodeEthereumLogWithContract ¶
func DecodeEthereumLogWithContract(log types.Log, contract *contracts.Contract) (*EthereumLog, error)
DecodeEthereumLogWithContract decodes an Ethereum event log using the provided contract's ABI. It returns an EthereumLog instance containing the decoded event details such as the event name, data, and topics.
Example:
log := &types.Log{} contract := &contracts.Contract{} decodedLog, err := DecodeEthereumLogWithContract(log, contract) if err != nil { log.Fatalf("Failed to decode log: %v", err) }
type EthereumTopic ¶
type EthereumTopic struct { Name string `json:"name"` // The name of the topic. Value any `json:"value"` // The value of the topic, decoded into the appropriate Go data type. }
EthereumTopic represents a single decoded topic from an Ethereum event log. Topics are attributes of an event, such as the method signature and indexed parameters.
func GetEthereumTopicByName ¶
func GetEthereumTopicByName(name string, topics []EthereumTopic) *EthereumTopic
GetEthereumTopicByName searches for and returns a Topic by its name from a slice of Topic instances. It facilitates accessing specific topics directly by name rather than iterating over the slice. If the topic is not found, it returns nil.