Events Documentation
This guide describes the events emitted by the DiD Protocol smart contracts that integrators can use for indexing.
Events Overview
Events in DiD Protocol provide real-time updates about changes to names, ownership, addresses, and other state changes in the system. This allows integrators to maintain accurate, up-to-date indexes of the naming system.
Core Events
Registration Events
RegisterNameEvent
Emitted when a name (domain or subdomain) is registered.
struct RegisterNameEvent has drop, store {
owner: address,
domain_name: String,
domain_suffix: Option<String>,
subdomain_name: Option<String>,
registration_fee_octas: u64,
expiration_time_secs: u64,
registration_duration_secs: u64
}owner: Address of the new name ownerdomain_name: The registered domain namedomain_suffix: Optional domain suffix (e.g., "move")subdomain_name: Optional subdomain name if registering a subdomainregistration_fee_octas: Registration fee paid in Octasexpiration_time_secs: Unix timestamp when the registration expiresregistration_duration_secs: Duration of the registration in seconds
RenewNameEvent
Emitted when a name's registration is renewed.
domain_name: The renewed domain namedomain_suffix: Optional domain suffixsubdomain_name: Optional subdomain namerenewal_fee_octas: Renewal fee paid in Octasexpiration_time_secs: New expiration timestamprenewal_duration_secs: Duration of renewal in secondstarget_address: Current target address of the nameis_primary_name: Whether this name is set as primary name for its target address
Transfer Events
TransferNameEvent
Emitted when a name is transferred to a new owner.
domain_name: The transferred domain namedomain_suffix: Optional domain suffixsubdomain_name: Optional subdomain namefrom_addr: Previous owner's addressto_addr: New owner's address
Address Resolution Events
SetTargetAddressEvent
Emitted when a name's target address is updated.
domain_name: The domain namedomain_suffix: Optional domain suffixsubdomain_name: Optional subdomain nameexpiration_time_secs: Current expiration timestampnew_address: New target address (None if cleared)
SetTargetAddressByCAIPEvent
Emitted when a cross-chain address is set for a name.
domain_name: The domain namedomain_suffix: Optional domain suffixsubdomain_name: Optional subdomain namenew_address: New target address in string formatcaip: CAIP identifier for the chain
Reverse Resolution Events
SetReverseLookupEvent
Emitted when a reverse lookup (primary name) is set or cleared for an address.
account_addr: Address whose primary name is being set/clearedprev_*: Previous name details (if any)curr_*: New name details (None if clearing)
Metadata Events
SetAvatarUrlEvent
Emitted when an avatar URL is set for a name.
domain_name: The domain namedomain_suffix: Optional domain suffixsubdomain_name: Optional subdomain nameavatar_ipfs_hash: IPFS hash of the avatar (None if cleared)
SetKeyValueRecordEvent
Emitted when a key-value record is set for a name.
domain_name: The domain namedomain_suffix: Optional domain suffixsubdomain_name: Optional subdomain namekey: Record keyvalue: Record value (None if cleared)
Marketplace Events
ListDomainForSaleEvent
Emitted when a domain is listed for sale.
domain_name: The listed domain namedomain_suffix: Optional domain suffixprice: Listing price in Octasduration_secs: Duration of the listingexpiration_time: When the listing expiresseller: Address of the seller
ListingUpdatedEvent
Emitted when a domain listing is updated.
ListingBuyEvent
Emitted when a listed domain is purchased.
ListingCancelledEvent
Emitted when a domain listing is cancelled.
Best Practices for Indexing
Handle Reorgs: Always be prepared for blockchain reorganizations by implementing proper reorg handling in your indexer.
Process Events in Order: Events should be processed in the order they appear in blocks to maintain consistency.
State Validation: Periodically validate your indexed state against on-chain data to ensure accuracy.
Handle Missing Events: Implement retry logic for missed events and periodic state reconciliation.
Track Event Versions: If the event structure changes in future updates, maintain version compatibility in your indexer.
Technical Considerations
All timestamps are in Unix seconds
Fees and prices are in Octas (1 APT = 100000000 Octas)
String values for names should be stored as normalized lowercase
CAIP IDs follow the CAIP-2 specification for chain identification
Handle Option types appropriately - they may be None/null
Last updated