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
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 tofilters*
(object) -- an object of filterscontractAddresses*
([]string) -- an array of any contract addressevents*
([]string)-- any contract event, with the includedindexed
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 IDsaccounts
([]string) -- an array of wallet addresses to listen ontopicHashes
([]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 -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 fromAddWebhookListener
(i.e.response.listener.id
)projectId*
(string) -- the Project ID the JWT Secret API key was obtained from
Example:
RemoveWebhookListener
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 logtype
(string), -- the type of event (i.e.BLOCK_ADDED
)blockNumber
(i32) -- the block number from the blockchain for when the event occuredblockHash
(string) -- the hash of the block for the transactionparentBlockHash
(i32) -- the hash of the parent blockcontractAddress
(string) -- the contract address from where the event came fromcontractType
(string) -- the type of contract (e.g.ERC20
,ERC721
,ERC1155
, etc.)txnHash
(string) -- the transaction hash of the eventtxnIndex
(i32) -- the index of the transaction in the blockchain blocktxnLogIndex
(string) -- the log index in the transactionts
(date) -- an ISO 8601 formatted date and time of the eventevent
(event) -- the event data of the on-chain datatxnLogIndex
(string) -- the log index in the transactionlogDataType
(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 -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)
Field | Type | Description |
---|---|---|
topicHash | string | a hash of the event being listened to (e.g. ethers.id("Transfer(address indexed from, address indexed to, uint256 amount)")) |
eventSig | string | the event signature of the on-chain event (e.g. "Transfer(address indexed from, address indexed to, uint256 amount)") |
types | []string | an array of argument types from the event |
names | []string | an 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 | []string | an array of hex values corresponding to the argument names |
rawLog (object)
Field | Type | Description |
---|---|---|
data | string | data |
topics | []string | the topic event hashes emitted in the logs |