Sign Up
Skip to content

Webhooks

Webhooks are a feature that allows systems to be called upon across the internet based on the emission of a blockchain event that meets some criteria.

You can listen to transactions via webhooks using the Sequence Indexer by registering an endpoint or removing it after it's no longer required.

To begin, direct yourself to the Sequence Builder and follow this walkthrough for Public API Access Key and this walkthrough for a Secret API Access Key, both required for using the Sequence Indexer Webhooks.

Function

  1. Register a Webhook Listener
  2. Remove a Webhook Listener

Webhook Response

Example

1. Register a Webhook Listener

Our filters allow you to listen to on-chain events for particular contract addresses, contract events, specific token ids, account addresses, or topic hashes.

Sequence Indexer AddWebhookListener Method: with required* fields

  • Request: POST /rpc/Indexer/AddWebhookListener
  • Content-Type: application/json
  • Body (in JSON):
    • url* (string) -- the URL to send the webhook to
    • filters* (object) -- an object of filters
      • contractAddresses* ([]string) -- an array of any contract address
      • events* ([]string)-- any contract event, with the included indexed keyword from the contract when necessary (e.g. Transfer(address indexed from, address indexed to, uint256 amount). Shorthand is also acceptable without argument names, which will simply be parsed as: arg1, arg2, etc. i.e. Transfer(address indexed,address indexed,uint256) without argument names)
      • tokenIDs ([]int) -- an array of token IDs
      • accounts ([]string) -- an array of wallet addresses to listen on
      • topicHashes ([]string) -- a hash of the event being listened to (e.g. ethers.id("Transfer(address indexed from, address indexed to, uint256 amount)"))

Example: AddWebhookListener

Where this example listens to all mints of an ERC1155 collectible contract:

cURL
curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Access-Key: <project_access_key>" \
  -H "Authorization: BEARER <secret_API_key>" \
  -d '{
		"url": "<URL>",
        "filters": {
          "contractAddresses": ["0x9bec34c1f7098e278afd48fedcf13355b854364a"],
		  "events": ["TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)"],
        }
      }' \
  https://arbitrum-sepolia-indexer.sequence.app/rpc/Indexer/AddWebhookListener

2. Remove a Webhook Listener

If you need to clean up your webhook listeners, you can submit requests to remove the listener based on listener id and projectId:

Sequence Indexer RemoveWebhookListener Method: with required* fields

  • Request: POST /rpc/Indexer/RemoveWebhookListener
  • Content-Type: application/json
  • Body (in JSON):
    • id* (string) -- the id of the listener returned from AddWebhookListener (i.e. response.listener.id)
    • projectId* (string) -- the Project ID the JWT Secret API key was obtained from

Example: RemoveWebhookListener
cURL
curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Access-Key: <project_access_key>" \
  -H "Authorization: BEARER <secret_API_key>" \
  -d '{ "id": <listener_id>, "projectId": <project_id> }' \
  https://arbitrum-sepolia-indexer.sequence.app/rpc/Indexer/RemoveWebhookListener

Webhook Listener Response

Upon webhook listener response, an object is returned in the following structure

  • Response (in JSON):
    • uid (string) -- a deterministic hash value of the on-chain transaction log
    • type (string), -- the type of event (i.e. BLOCK_ADDED)
    • blockNumber (i32) -- the block number from the blockchain for when the event occured
    • blockHash (string) -- the hash of the block for the transaction
    • parentBlockHash (i32) -- the hash of the parent block
    • contractAddress (string) -- the contract address from where the event came from
    • contractType (string) -- the type of contract (e.g. ERC20, ERC721, ERC1155, etc.)
    • txnHash (string) -- the transaction hash of the event
    • txnIndex (i32) -- the index of the transaction in the blockchain block
    • txnLogIndex (string) -- the log index in the transaction
    • ts (date) -- an ISO 8601 formatted date and time of the event
    • event (event) -- the event data of the on-chain data
    • txnLogIndex (string) -- the log index in the transaction
    • logDataType (string) -- the type of log event (e.g. TOKEN_TRANSFER)
    • rawLog (raw) -- the raw transaction object

Example

Listen to a Specific Token ID for an ERC1155

If you want to get all mints and transfers of a specific token ID for an ERC1155

cURL
curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Access-Key: <project_access_key>" \
  -H "Authorization: BEARER <secret_API_key>" \
  -d '{
		"url": "<URL>",
        "filters": {
          "contractAddresses": ["0x9bec34c1f7098e278afd48fedcf13355b854364a"],
		  "events": ["TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)"],
          "tokenIDs": ["1237"]
        }
      }' \
  https://arbitrum-sepolia-indexer.sequence.app/rpc/Indexer/AddWebhookListener

On-chain Token Event Types

ERC20

  • Transfer(address indexed from, address indexed to, uint256 value)
  • Approval(address indexed owner, address indexed spender, uint256 value)

ERC721

  • Transfer(address indexed from, address indexed to, uint256 indexed tokenId)
  • Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)
  • ApprovalForAll(address indexed owner, address indexed operator, bool approved)

ERC1155

  • TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)
  • TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)
  • ApprovalForAll(address indexed account, address indexed operator, bool approved)
  • URI(string value, uint256 indexed id)

Custom Return Data Types Glossary

event (object)
FieldTypeDescription
topicHashstringa hash of the event being listened to (e.g. ethers.id("Transfer(address indexed from, address indexed to, uint256 amount)"))
eventSigstringthe event signature of the on-chain event (e.g. "Transfer(address indexed from, address indexed to, uint256 amount)")
types[]stringan array of argument types from the event
names[]stringan array of event argument names in plain text (note: if names are not included in initial webhook creation, will appear as: arg1, arg2, arg3, etc.)
values[]stringan array of hex values corresponding to the argument names
rawLog (object)
FieldTypeDescription
datastringdata
topics[]stringthe topic event hashes emitted in the logs