Skip to content

Transactions

Monitors single transactions using a TransactionFilter. The filter specifies things such as value, to and from addresses and event emissions. The handler function receives a TransactionEvent that contains all the information of the transaction that matched the filter.

TBD: we also want to support monitoring pending transactions and low level traces within this handler type or by adding new types.

Use cases

  • Monitor all token transfers that involve a specific wallet, and send notifications to a Discord server.
  • Build a simple indexer that pushes data about specific transactions to a database.
  • Copy trading strategies from another wallet.
  • ...

Examples

Monitor ETH -> WETH conversions with value > 0.1 ether

function setUp() external {
    TransactionFilter memory wethFilter = filter()
        .to(WETH)
        .value(gt(0.1 ether));

    register(wethFilter, this.handle);
}

function handle(TransactionEvent calldata ev) external {
    string memory message = string.concat(
        "EVENT MATCHED! https://etherscan.io/tx/",
        ev.hash.toString()
    );

    JsonObject memory body = json.create().set("content", message);

    request.create().post(WEBHOOK_URL).json(body).send();
}