Hey guys, as I understand it, data analytics (like calculating averages etc) on blockchain data is usually done off-chain (ie. you obtain data from the blockchain via say a third party API call or directly from the blockchain and then do the data analytics off-chain someone else).

Is it possible and/or if it is possible, how do we do data analytics on-chain itself (which I assume would involve doing the data analytics on the smart contract itself)?

Would really appreciate any help or input. Thanks!

  • hanniabu@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    You’ll only be able to do analytics on current data, or if you want historical data you’d need to start recording it and can only do historical data from that point on, unless you were to take past historical data from offchain and then save it to the smart contract.

    All of this is a moot point though, because it would be prohibitively expensive and very unrealistic to do. Not to mention you’d probably run out of block space.

      • hanniabu@alien.topB
        link
        fedilink
        English
        arrow-up
        1
        ·
        10 months ago

        It’d likely be a very large transaction and depending on how large of a dataset you’re working with you can potentially fill up an entire block with that one transaction. Granted, in reality a transaction that size will probably never make it into a block unless you pay a good validator tip since it’d be more profitable to leave that transaction out and get MEV from a bunch of smaller transactions.

  • vjeuss@alien.topB
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 months ago

    why would you want that? It would cost money, a smart contract doesn’t have wide visibility, no storage, …

    or maybe I missed the point

    • --leockl--@alien.topOPB
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      If the data analytics (along with storing the data) can be done on-chain in the smart contract itself, then this may perhaps reduce any latencies when the data analytics (along with storing the data) is done off-chain somewhere else (which relies on a different system which may perhaps have latencies).

      Yeah this would cost money since a smart contract needs to be deployed.

      A smart contract does have wide visibility though because it’s a smart contract deployed on the blockchain, hence it is transparent to everyone.