Skip to Content
DocumentationAnalog WatchDevelopers' GuideEvent Data Support

Event Data Support

Analog Watch makes it easy to work with event data. The GraphQL IDE  lets you specify the desired events, such as transfers, withdrawals, approvals, swaps, etc. to be retrieved from smart contracts. It’s noteworthy that event data support is currently available on Ethereum, Polygon, and Astar blockchains, with additional networks planned for future integration.

How It Works

Indexing an event from your smart contract is as simple as submitting a contract address and specifying the event name in the GraphQL IDE . In this example, we’ll guide you through querying thetransfer event for a smart contract deployed on Polygon.

Step 1: Navigate to the PolygonScan Explorer

  1. Select the contract from which you want to retrieve event data.
  2. Copy the contract address and check if it's already listed in our GraphQL IDE . If it is not listed, add the contract first.
  3. You can also check if the contract is listed using the Watch UI 

Step 2: Choose the event

  1. Choose the event you want to query from the contract, such as Transfer, Withdrawal, Approval, Swap, etc. For this example, we'll use the Transfer event.

Step 3: Configure Event Details in the GraphQL IDE

  1. Open the GraphQL IDE .
  2. Use the merge mutation to add the event to your View.
  3. Configure functions:
  • Name: xPolygon_c213_Transfer → (include the network and address in the name)
  • Network: "Polygon" → (specify the network)
  • Description: "Transfer event emitted for a DEX smart contract on the Polygon network."
  • Outputs:Configure the outputs. Here's the sample outputs:

Outputs

{ value: "data", name: "from" } { value: "data", name: "to" } { value: "data", name: "value" }
  • Input: → (Configure inputs based on the event)

Step 4: Configure Contract Details in the GraphQL IDE

  • Address: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F →(contract address from the Polygon Explorer)
  • ABI: name: "Transfer", type: "event"
  • Inputs: Configure your inputs as shown here:

Inputs

[{ type: "address", indexed: true }, { type: "address", indexed: true }, { type: "uint256", indexed: false }]
  • Outputs: []

Step 5: Create a View for the Event

Create a View (custom query) for the event. You can combine multiple events or smart contract functions if needed. For this example, we'll create a View with the Transfer event.

  • name: xPolygon_c213_Transfer_Event → (include the address and network in the name)
  • sql: SELECT * FROM 'xPolygon_c213_Transfer'
  • description: Event view for Transfer events on a DEX smart contract on the Polygon network.

Here’s a mutation request example for a View:

Mutation Request Example

mutation EventCreation { merge( functions: [ { name: "xPolygon_c213_Transfer" network: "Polygon" description: "Transfer event emitted for DEX smart contract on Polygon network." outputs: [ { value: "data", name: "from" } { value: "data", name: "to" } { value: "data", name: "value" } ] inputs: [] contract: { address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" abi: { name: "Transfer" type: "event" inputs: [ { type: "address", indexed: true } { type: "address", indexed: true } { type: "uint256", indexed: false } ] outputs: [] } } } ] views: [ { name: "xPolygon_c213_Transfer_Event" sql: "SELECT * FROM '{xPolygon_c213_Transfer}'" description: Event view for Transfers that occur on DEXapp for on Polygon network.” } ] ) { status views { status error name header view { name identifier hashId status { errors { at } updates { at } } creator } } functions { function { hashId name contract { abi { name outputs { type indexed __typename } inputs { type indexed __typename } anonymous } address } description identifier } } } }

Step 6: Session Key Authorization

Pass the authorization token and session key (SSK) in the header of your request like this:

{ "Authorization": Use your session key}

Step 7: Sponsor the event View

  1. Use the View name from the previous step to locate the View to sponsor.
  2. Execute a mutation request to sponsor the View. Here’s an example:
mutation sponsorView { sponsorView(viewName: "xPloygon_7ceB_Transfer_Event", amount: "2000000000") { status error amount view { sql hashId name identifier description references { hashId } creator viewId } } }

Alternatively, you can sponsor Views directly by searching their name on the Watch Portal . Simply locate the view you want on the Watch Portal and sponsor it.

Step 8: Query the view

Finally, query the View to retrieve the data by executing the following request:

Query View

query global { global { query(view: "xPloygon_7ceB_Transfer_Event") { header data schema } } }