Webhooks

What is webhooks?

Webhooks are a method of real-time communication between web applications. They are automated messages or notifications sent from one system to another when a specific event occurs. Essentially, webhooks allow one application to notify another of events that trigger an immediate action or response.

Webhooks are preferred over continuous polling for the following reasons:

  1. Real-time updates: Webhooks provide real-time updates. When an event occurs, a webhook immediately triggers an action in the receiving application. This is different from polling, which repeatedly checks for updates at predefined intervals.

  2. Efficiency: Polling is inefficient, especially if there are no updates. It requires periodic API requests even if there is no new data. in contrast, webhooks are event-driven, which means they only send data when an event occurs, reducing unnecessary traffic and server load.

  3. Less Latency: Webhooks minimize latency. Because Webhooks send updates in real-time, you can get the latest data as soon as it becomes available. With polling, you may experience delays depending on the frequency of polling.

  4. Simple: Setting up a webhook requires configuration of the source application to send data to a specified endpoint. Polling, on the other hand, is more complex as it requires writing and maintaining code to periodically query the API.

Simply put, webhooks in Web3 games provide a mechanism for real-time communication and data synchronization, making the gaming experience more dynamic and engaging, while also improving the operational efficiency of blockchain-based games.

What can webhooks offer?

In Web3 games, webhooks can serve a variety of purposes to enhance the gameplay experience and simplify operations. Common use cases are listed below:

  1. Real-time game events: Webhooks are a powerful tool for sending real-time notifications to players, game servers, or other applications whenever an event related to an on-chain asset requested by a partner occurs. For example, if certain events depend on the minting, transferring, burning, or updating of an asset's metadata; webhooks are an efficient way for partner applications to receive alerts when these events occur.

  2. Marketplace Updates: Webhooks allow third-party marketplaces to know the status of in-game assets listed on multiple platforms. They receive instant updates when items are listed or sold elsewhere, ensuring accurate inventory management for traders and collectors.

  3. Analytics and Metrics: Webhooks sends game-related data to an analytics platform, enabling game developers to track player behavior, identify trends, and make decisions to improve the game based on the data.

  4. Synchronized Databases: With Webhooks, third parties can keep a local copy of the GMLayer Blockchain Data API database. External databases can be mapped to GMLayer's records by receiving notifications when an event occurs that changes the state of an asset, token, or collection.

Event Subscription

The events below can be requested through a single Webhook connection:

Activity GroupTypeNode

Activity

imtbl_zkevm_activity_mint; imtbl_zkevm_activity_burn; imtbl_zkevm_activity_transfer; imtbl_zkevm_activity_sale; imtbl_zkevm_activity_deposit; imtbl_zkevm_activity_withdrawal

This activity provides details of minted coins (NFT (Non-Fungible Token)), transfers (NFT (Non-Fungible Token)), burned coins (NFT (Non-Fungible Token)), transactions (NFT (Non-Fungible Token)), withdrawals (ERC20) and deposits (ERC20) on the GMLayer'zkEVM blockchain.

These activity are great for tracking NFT (Non-Fungible Token) ownership changes, as well as monitoring blockchain activity to trigger application updates. No metadata is included in these event types.

Collection

imtbl_zkevm_collection_updated

The activity is signaled when a collection is created or modified. The payload of these events contains the metadata of the collection.

NFT (Non-Fungible Token)

imtbl_zkevm_nft_updated

This activity signals when an NFT (Non-Fungible Token) is created or modified. It consists of a token_id to metadata_id mapping that links the metadata stack to each NFT (Non-Fungible Token). When mapped to metadata_updated, this system allows assets to be mapped to their respective metadata, providing a comprehensive view of NFTs and their associated metadata in the GMLayer ecosystem.

Metadata

imtbl_zkevm_metadata_updated

This activity provides detailed information about the properties of metadata stacks, each of which is identified by a unique metadata_id.This event is triggered when a new metadata stack is created and when an existing stack is updated through the Metadata Refresh service.

Token

imtbl_zkevm_token_updated

This activity is signaled when a new ERC20 token is deployed on GMLayer's zkEVM platform.

Order

imtbl_zkevm_order_updated

This event signals when a new order (list) appears on a third-party marketplace. Orders are processed centrally through GMLayer's central order book.

Trade

imtbl_zkevm_trade_created

This event signals when a transaction occurs on the GMLayerGlobalOrderbook. The details of the transaction (including additional fees) are displayed.

Last updated