Set Conditions
Set Contract Event and Webhook Conditions.
import { CHAIN_NAME } from "lit-listener-sdk";
import { BigNumber } from "ethers";
newCircuit.setConditions(
[
new ContractCondition(
"0x6968105460f67c3bf751be7c15f92f5286fd0ce5", // contract address
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
], // abi
CHAIN_NAME.polygon, // chainId
"https://your_provider_url_for_this_network", // provider URL
"Transfer", // event name
["to", "value"], // event name args
["0x6968105460f67c3bf751be7c15f92f5286fd0ce5",
BigNumber.from("500000")], // expected value
"===", // match operator
async (emittedValue) => { console.log("Value Emmited by the contract event", emittedValue); }, // onMatched function
async (emittedValue) => { console.log("Value Emmited by the contract event", emittedValue); }, // onUnMatched function
(error: Error) => { console.log("Error:", error); } // onError function,
),
new WebhookCondition(
"https://api.example.com", // baseUrl
"/endpoint", // endpoint
"path.to.value", // responsePath
20, // expected value
"===", // match operator
"my-api-key", // apiKey
async (emittedValue) => { console.log("Value Emmited by the webhook event", emittedValue); }, // onMatched function
async (emittedValue) => { console.log("Value Emmited by the webhook event", emittedValue); }, // onUnMatched function
(error: Error) => { console.log("Error:", error); } // onError function,
)
]
)Last updated