Skip to content

Events

Events represent state changes, like a new message or contract event.

Snapchain nodes emit events whenever they observe a state change. Clients can subscribe to a node using the Events API to get a live stream of changes.

Snapchain keeps events around for 3 days after which they are deleted to save space. To get older data, use the GRPC or HTTP APIs.

HubEvent

FieldTypeLabelDescription
typeHubEventTypeThe type of event
iduint64Unique identifier for the event that encodes block height ordering
block_numberuint64The block number when the event was created
shard_indexuint32The shard index where the event occurred
timestampuint64The timestamp when the event was created
bodyMergeMessageBody, PruneMessageBody, RevokeMessageBody, MergeUserNameProofBody, MergeOnChainEventBody, MergeFailureBody, BlockConfirmedBodyoneOfThe event payload

Event ID Construction

Event IDs are constructed to ensure chronological ordering by block. The ID combines:

  • The block height (when the event was created)
  • A sequence number within that block

This design allows clients to determine which events occurred in the same block and their relative order, which is useful for processing events in chronological sequence.

HubEventType

NameNumberDescription
HUB_EVENT_TYPE_NONE0
HUB_EVENT_TYPE_MERGE_MESSAGE1
HUB_EVENT_TYPE_PRUNE_MESSAGE2
HUB_EVENT_TYPE_REVOKE_MESSAGE3
HUB_EVENT_TYPE_MERGE_USERNAME_PROOF6
HUB_EVENT_TYPE_MERGE_ON_CHAIN_EVENT9
HUB_EVENT_TYPE_MERGE_FAILURE10
HUB_EVENT_TYPE_BLOCK_CONFIRMED11

MergeMessageBody

FieldTypeLabelDescription
messageMessage
deleted_messagesMessagerepeated

MergeUserNameProofBody

FieldTypeLabelDescription
username_proofUserNameProof
deleted_username_proofUserNameProof
username_proof_messageMessage
deleted_username_proof_messageMessage

PruneMessageBody

FieldTypeLabelDescription
messageMessage

RevokeMessageBody

FieldTypeLabelDescription
messageMessage

MergeOnChainEventBody

FieldTypeLabelDescription
on_chain_eventOnChainEvent

OnChainEvent

FieldTypeLabelDescription
typeOnChainEventTypeThe type of onchain event
chain_iduint32The chain id for the event
block_numberuint32The block number for the event
block_hashbytesThe block hash for the event
block_timestampuint64The block timestamp for the event
transaction_hashbytesThe transaction hash for the event
log_indexuint32The log index for the event
fiduint64The fid the event is associated with
bodySignerEventBody, SignerMigratedEventBody, IdRegisterEventBody, StorageRentEventBody, TierPurchaseBodyoneOf
tx_indexuint32The tx index for the event

OnChainEventType

NameNumberDescription
EVENT_TYPE_NONE0
EVENT_TYPE_SIGNER1
EVENT_TYPE_SIGNER_MIGRATED2
EVENT_TYPE_ID_REGISTER3
EVENT_TYPE_STORAGE_RENT4
EVENT_TYPE_TIER_PURCHASE5

SignerEventBody

FieldTypeLabelDescription
keybytesThe bytes of the public key for the signer
key_typeuint32The type of the key (currently only set to 1)
event_typeSignerEventTypeThe type of the signer event
metadatabytesThe metadata associated with the key
metadata_typeuint32The type of the metadata (currently only set to 1)

SignerEventType

NameNumberDescription
SIGNER_EVENT_TYPE_NONE0
SIGNER_EVENT_TYPE_ADD1
SIGNER_EVENT_TYPE_REMOVE2
SIGNER_EVENT_TYPE_ADMIN_RESET3

SignerMigratedEventBody

FieldTypeLabelDescription
migratedAtuint32The timestamp at which nodes were migrated to OP mainnet

IdRegisterEventBody

FieldTypeLabelDescription
tobytesThe address the fid was registered/transferred to
event_typeIdRegisterEventTypeThe type of the id register event
frombytesThe address the transfer originated from
recovery_addressbytesThe recovery address for the fid

IdRegisterEventType

NameNumberDescription
ID_REGISTER_EVENT_TYPE_NONE0
ID_REGISTER_EVENT_TYPE_REGISTER1
ID_REGISTER_EVENT_TYPE_TRANSFER2
ID_REGISTER_EVENT_TYPE_CHANGE_RECOVERY3

StorageRentEventBody

FieldTypeLabelDescription
payerbytesThe address of the payer
unitsuint32The number of units of storage purchased
expiryuint32The timestamp at which these units of storage will expire

TierPurchaseBody

FieldTypeLabelDescription
purchaserbytesThe address of the purchaser
tieruint32The tier number purchased
unitsuint32The number of units purchased
expiryuint32The timestamp at which tier expires

MergeFailureBody

FieldTypeLabelDescription
messageMessageThe message that failed to merge
errorstringThe reason for the merge failure

BlockConfirmedBody

FieldTypeLabelDescription
block_numberuint64The block number that has been confirmed
block_hashbytesThe hash of the confirmed block
shard_indexuint32The shard index of the confirmed block