event.decode
Normalizes the ENS events in logs or transaction receipts. Parameters, return value, errors and examples for event.decode in @ensforge/sdk.
Normalizes the ENS events in logs or transaction receipts.
When to use
Use to read what a write did from its receipts, or to classify logs you fetched yourself.
Details
- Each event carries the indexer's
typeandaction(bigname's model), the Solidity event name, protocol, emitter, decoded arguments and, when the event spells it, the name. - Logs that are not ENS events (token transfers, other contracts) are skipped.
- No RPC calls.
Signature
function decode(client: Like, options: decode.Options): Promise<decode.ReturnType>Call it as ens.event.decode(options) on a client, or Actions.event.decode(client, options).
event.decode.request(options) builds a deferred read for Actions.batch. See Look up many at once.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
logs | readonly Log[] | Logs to decode. | |
receipts | readonly TransactionReceipt[] | Receipts whose logs to decode. |
Returns
Resolves to readonly Event[]. The ENS events, in log order.
| Field | Type | Description |
|---|---|---|
type | EventType | |
action | EventAction | |
event | string | Solidity event name, e.g. LabelRegistered. |
protocol | "v1" | "v2" | null | Protocol of the emitting contract; null for resolvers ensforge does not know. |
contract | Address | Emitting contract. |
name | string | null | The name the event is about, when the event or the query reveals it. |
node | Hex | null | ENS node the event is keyed by, for node-keyed events. |
args | Readonly<Record<string, unknown>> | Decoded event arguments. |
blockNumber | bigint | |
transactionHash | Hex | |
logIndex | number |
Errors
| Error | Codes | When |
|---|---|---|
InternalError | UNEXPECTED | malformed logs. |
NetworkError | RPC_REQUEST_FAILED, RPC_TIMEOUT, RATE_LIMITED | the RPC request fails. |
It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).
See How errors work.
Examples
const events = await ens.event.decode({ receipts })See also
event.getto fetch a name's events
Was this page helpful?