0

I want to determine the number of transactions of a contract in a certain period. My question is that in the transaction receipt, if we want to say that contract A has x number of transactions will these be only the transactions sent from this contract or they will be also the one sent to it, i.e. the sum of transaction numbers having this contract address in the to and from fields in the transaction receipt.

  • you can use etherscan io api – AVATAR Oct 31 '18 at 11:38
  • I dont want to find the total number of transactions of a contract, rather want to find them in a certain period for which i am utilizing getting transaction information from individual blocks. – mahamzaidi Oct 31 '18 at 11:40
  • you can use nonce for that – AVATAR Oct 31 '18 at 11:43
  • I dont think you are understanding my question – mahamzaidi Oct 31 '18 at 11:48
  • you want the number of transactions 'from' the contract or 'to' the contract? – Jaime Oct 31 '18 at 11:52
0

If the contract is emiting logs for each transaction received then you just need to look for the logs emitted by the contract.

You can do this with etherescan: https://etherscan.io/apis#logs

For instance: https://api.etherscan.io/api?module=logs&action=getLogs &fromBlock=379224 &toBlock=latest &address=0x33990122638b9132ca29c723bdf037f1a891a70c &apikey=YourApiKeyToken

will return a list of all the logs generated by the contract (presume a single event per transaction)

Notice that you can decide what from what interval (in blocks) to look for.

The only caveats possible are:

  1. The contract do not generate an event for every transaction.
  2. The contract generates more than one event per transaction.
|improve this answer|||||
0

This depends on what do you mean by ”transaction” and what do you mean by “transaction of a contract”.

For transaction there could be at least two meanings:

  1. Real Ethereum transaction included into a block with separate hash, receipt etc.
  2. So called “internal” transaction, initiated by a smart contract, that does not have hash nor receipt.

For “transaction of a contract” possible meanings are:

  1. Transaction sent to this contract.
  2. Transaction sent by this contract (internal transaction).
  3. Transaction that created this contract.
  4. Transaction that destroyed this contract.
  5. Transaction that destroyed some other contracts sending remaining ether from the balance of destroyed contract to this contract without executing this contract's byte code.
  6. Transaction that accessed this contract without executing its byte code, i.e. read ether balance of this contract or byte code of it.
  7. Transaction that performed delegate call to this contract.

You need to use different approaches to detect and count different kinds of transaction related to the contract in different ways. In some cases Web3 API will be enough, but in the other cases, you will need to trace transactions all use etherescan.io API.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.