An Introduction to Analyzing NEAR Data on Dune

4 min read

New to analyzing NEAR data and want to learn? Then you’re in the right place! Whether you’re a Dune veteran or just starting out this course will cover everything you need to know to get started analyzing the NEAR blockchain using Dune.

This guide is accompanied by a detailed video tutorial for those who prefer learning visually.

This course is for all levels:

  • If you are new to NEAR, spend some extra time on the beginning sections understanding how NEAR transactions, receipts, and sharding work. This will help set your foundation as we learn which tables to pull information from
  • If you are familiar with NEAR but new to Dune, focus on the ‘Getting Started with Dune’ section of the guide. Navigating the Dune UI and finding the right tables will make your learning journey smooth.
  • If you are familiar with both NEAR and Dune, feel free to dive right into the educational queries. We’ll cover beginner, intermediate, and advanced queries.

Overview of NEAR blockchain

NEAR is a layer one, sharded, proof-of-stake blockchain. That was a lot. So what does this all mean?‍

  1. Sharding for Efficiency: NEAR employs sharding to split the network into parallel processing units to increase transaction speed and performance.‍
  2. Proof-of-Stake Consensus: By using a proof-of-stake mechanism, NEAR minimizes energy consumption.

Advantages as an Analyst:

  1. ‍Human readable accounts/addresses:
    ‍
    NEAR uses human-readable account names like sector.near, instead of hexadecimal-encoded addresses such as 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 used on EVM (Ethereum Virtual Machine). You can think of this like using ENS names natively.
  2. ‍Native Account Abstraction
    User accounts can also be contracts! You also don’t always need your own gas to transact.
  3. ‍Raw data tables have human readable actions and logs on Dune!

How to quickly access Dune and its query engine

Here is a fantastic overview by Andrew Hong on how to navigate Dune and its query engine. Make sure you get familiar with the site before we begin writing any queries.

How to access NEAR specific tables

Once you’ve created a new query, NEAR tables are located in the Data Explorer on the left-hand side of the Dune interface. Here’s how to find them:

  1. Navigate to Data Explorer on the left menu.
  2. Scroll down and click on “Raw Blockchain Data”. This will display raw datasets for all chains supported by Dune.
  3. Scroll down the list or use the search bar to type “NEAR”.
  4. Select NEAR from the list to access its datasets.

You should now see the page shown below, which contains all NEAR-specific tables.

word-image-72604-2

Where can you find NEAR-specific data tables in the Dune interface?

Correct! Wrong!

Explanation of NEAR-specific data structures, terminology and flow

Transaction Structure in NEAR

  • A transaction is a high-level operation submitted by a user/account to interact with the blockchain.Note: Unlike many blockchains with a transactions table on Dune, NEAR does not have a near.transactions table. Instead, transaction-related data is captured in the near.actions table. This table breaks down transactions into their individual actions, with each row representing a unique action. So what are actions? I’m glad you asked.
  • An action is a discrete operation within a transaction that defines what the transaction aims to accomplish. A transaction can include multiple actions, such as transferring tokens or calling a smart contract. Here is the full list of available actions available:
    1. CreateAccount
    2. DeployContract
    3. FunctionCall
    4. Transfer
    5. Stake
    6. AddKey
    7. DeleteKey
    8. DeleteAccount
    9. Delegate
  • These actions are grouped together within a single transaction and processed sequentially or asynchronously, depending on their complexity.
  • After a transaction is submitted and executed (via the ExecutionOutcome), it is converted into a series of one or more receipts. These receipts are used to process the actions specified in the transaction, enabling asynchronous execution. This structure is critical for cross-shard operations and can get quite complex. For now, all you need to know is that transactions are converted into receipts, which carry the necessary information to interact with smart contracts and execute the desired actions.
  • Finally, after a receipt is executed, logs are emitted by the smart contracts. We’ll be using near.logs on Dune to extract useful information.

How does Dune represent NEAR transactions in its datasets?

Correct! Wrong!

How does Dune represent NEAR transactions in its datasets?

Correct! Wrong!

word-image-72604-3

Optional Exercises

Ready to dive deeper and test your skills? Try your hand at analyzing the data with these exercises! Follow along with the accompanying video tutorial for this section. You can watch it here. The queries, along with additional metrics, are also available on this dashboard.

Basic Queries:

Intro to querying near.actions on Dune

  1. Let’s look at a transaction example:
    ‍dune.com/queries/4575420‍
  2. How many successful transactions occurred on 2025-01-01?
    Answer: dune.com/queries/4575423‍
  3. How many times was each action_kind called on 2025-01-01?
    Answer: dune.com/queries/4575426

Intermediate Queries

Let’s analyze the top DEX on NEAR: Ref.Finance

  1. Find all ‘simple pools’ deployed on ref-finance
    Answer: dune.com/queries/4575590‍
  2. What are the weekly number of pools deployed? Deployers?
    Answer: dune.com/queries/4575594‍
  3. What is the most common ‘simple pool’ pair(tokenA-tokenB) deployed?
    Answer: dune.com/queries/4575601‍
  4. Bonus Questions: Find power users: Top 10 Pool Deployers

Advanced Queries

  1. Find all swap on Ref.Finance after 2025-01-01
    Answer: dune.com/queries/4575620
  2. What was the daily number of swaps for all USDC/wNEAR pairs?
    Answer: dune.com/queries/4575631‍
  3. What was the daily swap volume for all USDC/wNEAR pair?
    Answer: https://dune.com/queries/4575638
10

1 thought on “An Introduction to Analyzing NEAR Data on Dune”

Leave a Comment


To leave a comment you should to:


Scroll to Top