7 days to become a NEAR data wizard

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.

Join the "7 Days to Become a NEAR Data Wizard" Campaign!

We’re bringing the wizard community together to make learning NEAR data on Dune accessible and fun for everyone. From January 30th to February 6th, 2025, we’ll feature 2-3 participants daily on our socials who share their learning experiences.

Here’s how you can join the journey and get featured:

  1. Follow Dune on socials
    Stay updated by following us on X (formerly Twitter), LinkedIn, and signing up for our newsletter. You’ll get new tutorials, product updates, and resources to level up your skills.
  2. Join the Dune Discord
    Connect with a community of fellow wizards, ask questions, share tips, and get inspired by other analysts working with NEAR data.
  3. Document your learning journey
    Share your experiences on socials! Tag @Dune and use #NEARwizard to amplify your posts and engage with the community.

Not sure what to post? Here are some ideas:

  • What inspired you to become a NEAR Data Wizard?
  • Highlights from your learning journey: a simple SQL query, new datasets you discovered, or complex questions you’re tackling.
  • Dashboards or charts you’ve built after following this guide.
  • Insights you’ve uncovered about the NEAR blockchain ecosystem.
  • Feedback about the tutorials, the Dune platform, or NEAR blockchain itself.
  • Anything else you want to share—your creativity is the limit!

Note: This guide is structured into daily lessons to guide you through the process step by step. However, feel free to learn at your own pace and explore the areas that interest you most!

Getting Started

Day 1:

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 it’s 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.

Day 2:

Explanation of NEAR-specific data structures, terminology and flow

Transaction Structure in NEAR

  1. 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.
  2. 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:

    - CreateAccount
    - DeployContract
    - FunctionCall
    - Transfer
    - Stake
    - AddKey
    - DeleteKey
    - DeleteAccount
    - Delegate
  3. These actions are grouped together within a single transaction and processed sequentially or asynchronously, depending on their complexity.
  4. 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.
  5. 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.

Day 3:

Receipt System Overview

NEAR uses a receipt-based execution model to handle transaction actions. You can think of a receipt as an internal transaction on the NEAR protocol.

Receipts are created to handle asynchronous/parallel execution (remember sharding?), especially when cross-contract calls are involved.

Key Points:

  1. All successful transaction actions get converted into one or more receipts. Note: Not all actions generate a unique receipt.
  2. An additional unique receipt is created when an action requires further asynchronous execution (e.g., cross-contract calls or sending funds to another account).
  3. Actions that are resolved immediately (e.g., token transfers or local contract calls) do not generate additional receipts.

Receipt Lifecycle:

  1. Initial Receipt: A receipt is first created when a transaction is submitted, representing the set of actions in the transaction.
  2. Execution Receipts: If a transaction involves cross-contract calls or complex interactions, additional execution receipts are created to handle the intermediate steps.
  3. Final Outcome: The receipt system ensures that all actions within the transaction are executed, even if they span multiple shards or contracts.

One final note that caught me off guard coming from other blockchains. Although rare, on NEAR a transaction can be successful while having a failed receipt. So make sure to add the appropriate filters when analyzing data. See example below:

1SELECT * 
2FROM near.actions
3WHERE
4    tx_status = 'SUCCESS_RECEIPT_ID' - - The status of the transaction, indicating success or failure.
5AND
6   execution_status != 'FAILURE' - - The status of the execution of the action.


If you are coming from Ethereum or Solana data, transaction flow on NEAR can be a little tricky to wrap your head around. Here are some additional resources and learning materials to help you out:

  1. Official NEAR Docs
  2. Additional Documentation
  3. Working with JSON, VARCHAR, ARRAY data types
    Dune documentation
    Trino Documentation
    Trino-Oreilly-Guide.pdf

Day 4:

Step-by-Step Examples

Make sure to 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

Day 5:

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

Day 6:

Advanced Queries

  1. Find all swap on Ref.Finance after 2025-01-01
    Answer: dune.com/queries/4575620
    Note: I technically should have joined the near.actions table with the near.logs table to verify the parent transaction was successful, not just the receipt.
  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
    Note: I made a silly mistake carrying incorrect decimals in the video tutorial. I’ve fixed this on the linked query.
  4. Bonus Questions:

    How many users (accounting for relayers) have swapped USDC AND wNEAR in 2025?

    Find the top ten users that have gained the most swap referral fees on Ref.Finance?

    Find the amount of liquidity added and removed from any pool. What is the current liquidity of the pool? Which pool has the most liquidity?

Day 7:

Final Challenge

Now that you’ve learned the fundamentals, it’s time to put your skills into action!

Find a protocol you’re passionate about, analyze its data, and share your findings with the community on twitter. Make sure to tag @0xSector and @Dune team as we’d love to see your results and provide feedback to help you refine your analysis!

Congratulations on mastering the basics of NEAR data on Dune! 📊

You’ve just taken a huge step toward understanding and analyzing NEAR’s blockchain data. From crafting queries to building dashboards, you’re now equipped to explore insights that power the NEAR ecosystem.

Remember, data is only as powerful as the questions you ask. Keep experimenting and refining your skills. If you have any questions or feedback my DM’s on Twitter are always open. Let’s keep learning together.

Transcript

Up next

View all
No related videos found
View all guides

Ready to get started?

Individuals + Small Teams

Create and explore queries, dashboards and trends with 500k+ data analysts.

Enterprise

Tailored solutions trusted by 6k+ Web3 teams and premier enterprises