Close Menu
Chain Tech Daily

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    SwissBorg loses $41M in Solana following API-related hack

    September 9, 2025

    Mt. Gox wallet with 80,000 BTC attacked via OP_RETURN message

    September 9, 2025

    Altair Mainnet Announcement | Ethereum Foundation Blog

    September 9, 2025
    Facebook X (Twitter) Instagram
    Chain Tech Daily
    • Altcoins
      • Litecoin
      • Coinbase
      • Crypto
      • Blockchain
    • Bitcoin
    • Ethereum
    • Lithosphere News Releases
    Facebook X (Twitter) Instagram YouTube
    Chain Tech Daily
    Home » The Graph vs Alethio vs web3JS
    Crypto

    The Graph vs Alethio vs web3JS

    James WilsonBy James WilsonJuly 13, 20254 Mins Read
    Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Tumblr Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    A practical exercise using the Aave protocol

    Introduction

    There is always talk about the clarity of blockchain, that everything is traceable and everyone can see what was written but is it easy to access this information? How can I get data to do my analysis in a simple way?

    In this post we are going to see three ways to do it, using the DeFi Aavesome protocol as an example, in which we are going to obtain the history of deposits made on the platform, using three different methods:

    • The Graph: A protocol for building decentralized applications using GraphQL.
    • alethio: An API rest to obtain data from the blockchain in a friendly way.
    • Web3 Foundation Team: Reading the events directly on the blockchain using the web3js library

    Aave Data

    In order to access certain data on the blockchain, the easiest way is to query the events. When a function in a smart contract is called, if a certain action is executed, an event can be emitted, which can listen at that time by clients who are listening for that particular event, or in the future, accessing their history, which is recorded on the blockchain.

    In this case we want to see the history of deposits made in the Aave protocol, so we look inside its code if there is an event related to this.

    In its documentation, we see that if there is an event for this and it contains the following data:

    Aave docAave doc

    But if we don’t want to trust the documentation and see it in the code, let’s see the contract deployed on mainnet and look in code in the part:

    EtherscanEtherscan

    Which contains this event, if we want to see in detail the moment in which it is generated we see that it is done once the deposit function is finished, therefore it is what we are looking for:

    The Graph vs Alethio vs web3JSThe Graph vs Alethio vs web3JS

    Getting the data

    Once we are clear about what we are looking for, we will obtain these data in three different ways.

    The Graph

    Aave’s team has created a subgraph that can be tested in this playground.

    As an example, we want to extract the deposit id, and the amount that was deposited in it, to then do our analysis, for this we use the query

    {
      deposits(first:1000, skip:0){
       id,
       amount
      }
    }

    that returns the data of the same

    transactiontransaction

    We would have to repeat this query n times, advancing the skip parameter from 1000 to 1000 to bring up the next block of data.

    Alethio

    Now we are going to obtain it using the Alethio api, for this we will use the endpoint:

    https://api.aleth.io/v1/log-entries?filter[loggedBy]=0x398eC7346DcD622eDc5ae82352F02bE94C62d119&filter[hasLogTopics.0]=0xc12c57b1c73a2c3a2ea4613e9476abb3d8d146857aab7329e24243fb59710c82

    Where we query the logs of the Aave’s smart contract address, and filter the logs, with the hash of the Deposit function

    The object returned by this endpoint indicates the event, with its parameters and the link to the “next” pages to bring in a new data block.

    Alethio apiAlethio api

    We iterate all of these “next” links by increasing the number of existing “Deposit” events.

    web3.js

    As a third option we will read the events directly from the blockchain, to do that, we will use the web3js library and we will get all the events of type “deposit” in the Aave contract, with a script like the following:

    const contract = new web3.eth.Contract(LendingPoolABI, LendingPoolAddress)
    return contract.getPastEvents('Deposit', {
       fromBlock: initBlock,
       toBlock: endBLock
    }, function (error, events) { return events })

    Comparing results

    Once we have created the three methods, we are going to execute them at the same time, to see that we have the same number of deposits and the information is correct, from three different sources, for this we execute the three methods and write the total number of events:

    console.log('Number of events with Alethio:', (await getDepositsAlethio()).length)
    console.log('Number of events with web3js:', (await getEventsWeb3js()).length)
    console.log('Number of events with The graph:', (await getDepositsGQL()).length)

    The output shows us:

    Number of events with Alethio: 31810
    Number of events with web3js: 31809
    Number of events with The graph: 31682

    Oops…. We have a discrepancy, in the case of Alethio and web3js, it is only one event, which occurred between executions, but the difference with The graph is bigger.

    Doing several tests I have verified that there is a certain delay from the generation of an event, until it is indexed in The graph, so if this event is consulted, nothing else is not found in The graph, but a few minutes later if it is, hence the discrepancy in the number of events recorded.

    In these three ways, you can consult the data, creating your own datasets with which build models, and verify that the information shown by these protocols is true. Do you think your bank would allow you to access the deposit history?



    Source link

    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Tumblr Email
    James Wilson

    Related Posts

    Crypto September 9, 2025

    SwissBorg loses $41M in Solana following API-related hack

    Crypto September 9, 2025

    Aethir price surges 43% amid fresh spike for DePIN tokens

    Crypto September 9, 2025

    MegaETH taps Ethena to launch USDm stablecoin and cut layer 2 fees

    Crypto September 8, 2025

    Nasdaq files with SEC to enable trading of tokenized securities

    Crypto September 8, 2025

    D.C. AG accuses Bitcoin ATM operator of actively enabling fraudsters

    Crypto September 8, 2025

    Hyperliquid price at record high; USDH vote and 80% fee cuts fuel rally

    Leave A Reply Cancel Reply

    Don't Miss
    Crypto September 9, 2025

    SwissBorg loses $41M in Solana following API-related hack

    SwissBorg, a Swiss crypto wealth management platform, suffered a $41 million hack on Sept. 8…

    Mt. Gox wallet with 80,000 BTC attacked via OP_RETURN message

    September 9, 2025

    Altair Mainnet Announcement | Ethereum Foundation Blog

    September 9, 2025

    Aethir price surges 43% amid fresh spike for DePIN tokens

    September 9, 2025
    Stay In Touch
    • Facebook
    • Twitter
    • YouTube
    • LinkedIn
    Our Picks

    SwissBorg loses $41M in Solana following API-related hack

    September 9, 2025

    Mt. Gox wallet with 80,000 BTC attacked via OP_RETURN message

    September 9, 2025

    Altair Mainnet Announcement | Ethereum Foundation Blog

    September 9, 2025

    Aethir price surges 43% amid fresh spike for DePIN tokens

    September 9, 2025

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    Don't Miss
    Crypto September 9, 2025

    SwissBorg loses $41M in Solana following API-related hack

    SwissBorg, a Swiss crypto wealth management platform, suffered a $41 million hack on Sept. 8…

    Mt. Gox wallet with 80,000 BTC attacked via OP_RETURN message

    September 9, 2025

    Altair Mainnet Announcement | Ethereum Foundation Blog

    September 9, 2025

    Aethir price surges 43% amid fresh spike for DePIN tokens

    September 9, 2025

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    About Us
    About Us

    ChainTechDaily.xyz delivers the latest updates and trends in the world of cryptocurrency. Stay informed with daily news, insights, and analysis tailored for crypto enthusiasts.

    Our Picks
    Lithosphere News Releases

    Imagen AI (IMAGE) Crypto Developer Launches Quantum Studio

    September 8, 2025

    Imagen Network (IMAGE) Adds XRP Ledger Support to Improve Blockchain Interoperability

    September 5, 2025

    Imagen Network (IMAGE) Developer Presents Plan to Buy $150M in Ethereum (ETH)

    September 4, 2025

    Imagen Network (IMAGE) Integrates Grok Intelligence to Expand Adaptive Creator Engagement

    September 2, 2025
    X (Twitter) Instagram YouTube LinkedIn
    © 2025 Copyright

    Type above and press Enter to search. Press Esc to cancel.