简体   繁体   中英

Track smart contract transactions

I am searching for an efficient way to track contract transactions.

Specifically, I want to receive an immediate notification when a specific function with a specific parameter is executed.

Any ideas or suggestions?

  • Run your own node
  • Subscribe to WebSocket hook to receive a notification for every transaction
  • Check if the transaction matches your parameters

The most efficient approach is to listen for new blocks and fetch every transaction from the block via GraphQL (I assume you use geth) which then gives you the block header, transaction and transaction receipt in a single http call.

From there you can ABI decode any transaction input which matches your function signature to obtain the function parameters and join that with the tx status from the receipt.

I am personally writing a similar component ( https://github.com/grassrootseconomics/cic-chain-events/ ) to track ERC20 transfers and notify users (SMS, Telegram, etc). You can borrow and extend concepts from it.

if within your smart contract function there are events emitted with the inputs that your user provide, then it will be possible to listen to those events (and thus your function call) and the corresponding transaction in real-time with Moralis Streams API.

Essentially to work with this, you will need a webhook where Moralis will be able to stream those events and transaction data constantly. To test it out really quickly, you can use https://webhook.site as a test webhook.

To get started with Streams API, you can follow this tutorial right here https://docs.moralis.io/streams-api/getting-started

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM