Amr Tawfik
Amr Tawfik

Reputation: 79

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?

Upvotes: 0

Views: 956

Answers (3)

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!

Upvotes: 1

Mohamed Sohail
Mohamed Sohail

Reputation: 1867

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, e.t.c). You can borrow and extend concepts from it.

Upvotes: 1

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83666

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

Upvotes: 1

Related Questions