Trigger Object
A function is defined with a list of triggers. When a function is invoked, it receives two objects: a context object and a data object. Amongst other relevant metadata, the context
object also includes the details of the specific trigger that matched and the on-chain data it matched on.
Each trigger object includes its type, along with type-specific parameters.
Address Trigger
Matches when the specified address shows up on the blockchain.
Example of a trigger set on the ENS deployer address:
{
"type": "TRIGGER_TYPE_ADDRESS",
"address": {
"address": "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5"
}
}
Event Trigger
Matches emitted events against an event signature and optional contract address.
Example of a trigger set on a Chainlink OwnershipTransferred event:
{
"type": "TRIGGER_TYPE_EVENT",
"eventSignature": {
"emitterAddress": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
"eventSignature": "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0"
}
}
Function Trigger
Matches when the specified function signature is called.
Example of a trigger set on the Uniswap V3: Factory
, createPool
function:
{
"type": "TRIGGER_TYPE_FUNCTION",
"functionSignature": {
"functionSignature": "0xa1671295"
}
}
New Block Trigger
Matches when a new block is created.
Example of a trigger set on a new block:
{
"type": "TRIGGER_TYPE_NEW_BLOCK",
"newBlock": {
"blockHash": "0x716e7e1be401470b7df66ff07e872b26b70667757d5a060e16edc2080774043d"
}
}
New Contract Trigger
Matches when a new contract is created.
Example of a trigger set on a new contract:
{
"type": "TRIGGER_TYPE_NEW_CONTRACT",
"newContract": {
"contractAddress": "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5"
}
}
Storage Access Trigger
Matches when the specified storage slot/variable are updated.
Note that setting a trigger on a variable is only possible if the contract's source code is available and was manually analyzed using SendBlocks' Analyze Contract endpoint in the past.
Example of a trigger set on the SushiBar
contract's _balances
variable:
{
"type": "TRIGGER_TYPE_STORAGE_ACCESS",
"storageAccessData": {
"storageAddress": "0x8798249c2e607446efb7ad49ec89dd1865ff4272",
"logicAddress": "0x8798249c2e607446efb7ad49ec89dd1865ff4272",
"accessSlot": "0xf889ad82841d18282efe448ad5544915fcea3a48e85996acf66f6275236c3974",
"baseSlot": "0x0",
"name": "_balances"
}
}
Updated 8 days ago