Web3Hook API
Web3Hook

Web3Hook

Overview

The Web3Hook API is divided into four endpoints: Create Hook, Get Hook, List Hooks, and Delete Hook. The Create Hook endpoint allows you to create hooks that can be configured to track log events or function calls as they happen. Instant notifications are delivered to a designated webhook URL. The Get Hook endpoint allows to see the details of a particular hook by specifying its id. The List Hooks endpoint provides an in-depth view of all currently active hooks to track the configuration and status of each hook. The Delete Hook endpoint is used to delete hooks that are no longer required. To delete a hook, you will need its id, which can be obtained using the List Hooks or Show Hook endpoints. The id can also be found in the output after creating a hook.

📘️

Multiple values can be set for these parameters: topic_0, topic_1, topic_2, topic_3, call, and contract, with a maximum of five items each.

Usage

In this example, we create a monitoring hook for every transfer made within the PRQ token's smart contract.

import * as Parsiq from '@parsiq/parsiq.js';
import {HttpAuthType} from "@parsiq/parsiq.js";
 
const client = Parsiq.createClient(process.env.API_KEY, Parsiq.ChainId.ETH_MAINNET);
 
const id = await client.web3Hooks.create({
    criteria: {
        topic_0: ['0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0'],
        contract: ['0x362bc847A3a9637d3af6624EeC853618a43ed7D2']
    },
    endpoint_auth: {
        type: HttpAuthType.basic,
        credentials: {
            username: "user",
            password: "qwerty"
        },
    },
    filter_type: 'events',
    name: 'PRQ Token Hook',
    description: 'Get all transfers within the PRQ token smart contract',
    endpoint_url: 'https://webhook.site/271ea63d-a6d7-4b43-8e43-e088abc3072f'
})
console.log(id)

Output:

{
    '31bcee1f-a98b-4427-af7a-3c66caa125e5'
}

Parameters

Path params
chainId
string
REQUIRED
version
string
REQUIRED
Query params
estimate_cu
boolean
Body params
abi
json
REQUIRED