Event decoders
Decode on-chain logs into typed event objects.
Utilities for decoding raw eth_getLogs entries into typed event objects.
Import
import {
decodeOnChainEvents,
TOKEN_TOPICS,
decodeConfidentialTransfer,
decodeWrap,
decodeUnwrapRequested,
decodeUnwrapFinalized,
findWrap,
findUnwrapRequested,
// ACL delegation events
ACL_TOPICS,
decodeDelegatedForUserDecryption,
decodeRevokedDelegationForUserDecryption,
decodeAclEvent,
decodeAclEvents,
findDelegatedForUserDecryption,
findRevokedDelegationForUserDecryption,
} from "@zama-fhe/sdk";decodeOnChainEvents
(logs: RawLog[]) => OnChainEvent[]
Decodes an array of raw log entries into typed event objects. Each returned event has an .eventName discriminator.
logs
RawLog[]
Raw log entries from eth_getLogs or a transaction receipt
Returns: OnChainEvent[] — each event has an .eventName of "ConfidentialTransfer", "Wrap", "UnwrapRequested", or "UnwrapFinalized".
TOKEN_TOPICS
Hex[]
Array of topic hashes for all supported token events. Pass this to eth_getLogs to fetch relevant logs in a single RPC call.
Individual decoders
Each decoder takes a single log entry and returns a typed event object, or null if the log does not match.
decodeConfidentialTransfer(log)
ConfidentialTransfer
Encrypted transfer between accounts
decodeWrap(log)
Wrap
Tokens wrapped (shielded)
decodeUnwrapRequested(log)
UnwrapRequested
Unwrap initiated; includes unwrapRequestId
decodeUnwrapFinalized(log)
UnwrapFinalized
Unwrap completed; includes unwrapRequestId
Convenience finders
Search a log array and return the first matching event.
findWrap
(logs: RawLog[]) => WrapEvent | null
Finds the first Wrap event in a set of logs. Useful after a shield transaction.
findUnwrapRequested
(logs: RawLog[]) => UnwrapRequestedEvent | null
Finds the first UnwrapRequested event in a set of logs. Useful after an unshield initiation.
ACL delegation events
The ACL contract emits events when delegations are created or revoked. These are separate from token events — they use their own topic hashes and decoders.
Import
ACL_TOPICS
Hex[]
Array of topic hashes for both ACL delegation events. Pass this to eth_getLogs to fetch delegation events from the ACL contract.
Individual decoders
decodeDelegatedForUserDecryption(log)
DelegatedForUserDecryption
Delegation created or renewed
decodeRevokedDelegationForUserDecryption(log)
RevokedDelegationForUserDecryption
Delegation revoked
DelegatedForUserDecryptionEvent
eventName
string
"DelegatedForUserDecryption"
delegator
Address
Account granting access
delegate
Address
Account receiving access
contractAddress
Address
Contract the delegation applies to
delegationCounter
bigint
Monotonic delegation counter
oldExpirationDate
bigint
Previous expiration (0 if first delegation)
newExpirationDate
bigint
New expiration timestamp
RevokedDelegationForUserDecryptionEvent
eventName
string
"RevokedDelegationForUserDecryption"
delegator
Address
Account that granted access
delegate
Address
Account that had access
contractAddress
Address
Contract the revocation applies to
delegationCounter
bigint
Monotonic delegation counter
oldExpirationDate
bigint
Expiration date before revocation
Convenience finders
findDelegatedForUserDecryption(logs)
First DelegatedForUserDecryptionEvent or null
findRevokedDelegationForUserDecryption(logs)
First RevokedDelegationForUserDecryptionEvent or null
Batch decoders
decodeAclEvent(log)
Try both ACL decoders on a single log, return first match
decodeAclEvents(logs)
Batch-decode an array of logs, skipping unrecognized entries
Related
Decrypt values from event logs — decrypt the encrypted amounts these decoders return
Delegated Decryption — delegation API with on-chain event examples
Token — high-level API for token operations
Last updated