Daily Volume and transactions

Hi there.
I would like to know how I could gather the volume and number of transactions of the token over the 24 hours time span.
I’ve tried some indexed API queries but I think im doing something wrong.
Can anyone give me suggestion how this can be achieved?

I’m thinking that you could sync the transactions for a particular token in a Moralis db table and than do a cloud function/job that iterates over a 24 hour interval.

What did you try by now?

Thats what I would like to avoid to do.
I’ve tried some graphql nodes available for BSC but I need a solution for BSC ETH and POLYGON.
With moralis I was thinking it will be possible to achieve via some of the endpoints on the index API like getting historical transactions for the address

you could get the list of transactions with a call like:

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/0x2170ed0880ac9a755fd29b2688956bd959f933f8?chain=eth' \
  -H 'accept: application/json' \
  -H 'X-API-Key: API_KEY'

but you’ll have to use a start_block and an end_block, use pagination and probably to post process every transaction in order to get the volume

example of output:

  "total": 5766,
  "page": 0,
  "page_size": 500,
  "result": [
      "hash": "0x99ff8293b469460ce53c7884a5a4131fb19ccdcac90b845a60a508d606a995b6",
      "nonce": "13",
      "transaction_index": "255",
      "from_address": "0x9a532241480ef7cd3451b8e781b34a0413170d89",
      "to_address": "0x2170ed0880ac9a755fd29b2688956bd959f933f8",
      "value": "0",
      "gas": "32916",
      "gas_price": "41238677437",
      "input": "0x095ea7b3000000000000000000000000a86b6018ffb7d29f9a3ab59ba27d9e424c1e2812ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
      "receipt_cumulative_gas_used": "20754030",
      "receipt_gas_used": "21944",
      "receipt_contract_address": null,
      "receipt_root": null,
      "receipt_status": "1",
      "block_timestamp": "2021-08-23T13:03:57.000Z",
      "block_number": "13081718",
      "block_hash": "0xfa1e7ed3362d2c16eda6ed5bd8cf47c842de380a514420864cb6a27016d36488"
1 Like

I see. And is there an easy way to decode the transaction output data?

this is what contains the details of the transaction right ?
"input": "0x095ea7b3000000000000000000000000a86b6018ffb7d29f9a3ab59ba27d9e424c1e2812ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
Also should I count all those transactions or onl the SELL/BUY. I believe in the output it will contain all sorts of transactions including approve/transfer/buy/sell and dunno how much more.

There should be a way to decode a transaction, but I don’t know how simple it is, this is an example of a swap transaction: https://etherscan.io/tx/0x13b853eddd7309447b25a35c526626ce5176d9b7831ccf4919834cbba12327f0