Data on the Blockchain | NEAR Documentation (2024)

This article will cover a high-level overview of Blockchain concepts and tools which facilitate reading and writing Blockchain data.

Writing data

By design, a Blockchain is a distributed database, and blockchain data is optimized to be stored in serialized blocks, writing one block at a time as the chain is being created. These serialized blocks store information about primitive components like transactions, accounts, and contracts.

Blockchain’s writing process provides a great way to apply the requested changes to the state in a decentralized manner. However, to observe the changes, you need to actively pull the information from the network. As a result, traversing several blocks and aggregating data is necessary when trying to get data across multiple contracts or a longer time range.

Reading data

Querying the Blockchain for data about a specific block or account is fairly straightforward and can be considered a "narrow" query. However, querying data across many blocks can be cumbersome because you must aggregate results from multiple single-block queries. Therefore, these can be considered "wide" queries.

info

The nature of a blockchain is that it must be deterministic. A critical feature of a blockchain is that it knows the state at a given block (or time unit). Think of them as snapshots – a blockchain does snapshots of its state on every block.

For example, a user can call a smart contract for a specific block, and the blockchain guarantees that the execution will always produce the same result for the same block any time you call it.

note

The deterministic nature of a blockchain isolates it from off-chain (external) variables. It is impossible to call an external API to read data from within a smart contract. Therefore, blockchains and smart contracts are closed-off from the outer (off-chain) world.

Information Availability

As mentioned, the essential information you can acquire from the Blockchain’s state is related to the transactions, accounts, and contracts taking place at a given block.

A simple way to get such information from the blockchain is using RPC. NEAR implements a JSON-RPC endpoint for everyone to interact with the blockchain. Through the JSON-RPC API, users can call smart contracts and view the data from the blockchain.Keep in mind that not all the data is available through the JSON-RPC. For example, local Receipts are unavailable through the JSON-RPC because they are not stored in the NEAR node's internal database.

tip

The JSON-RPC endpoint approach is the so-called pull model of getting the data. There is nothing wrong with this approach, but it is sometimes not the most comfortable or reliable alternative.

As you can imagine, this basic block information might not be enough for a complex project. For example, in an NFT marketplace, basic read operations via RPC calls could help get the status of a purchase or get the NEAR balance of an NFT creator account, but for information like getting the owner of a certain NFT, getting the metadata of an NFT based on its ID, or the total supply for a certain type of NFT, dApp developers would need to do additional parsing and processing after calling the RPC primitive methods.

More advanced real-world queries and operations like aggregation, search, relationships, and non-trivial filtering are simply not possible using RPC calls alone. An example of this is showing a leaderboard of the most popular NFT collections in the last 7 days. It would not be possible to get that information by interacting directly with the contract itself or via RPC. Getting this data would require processing every single transaction that ever happened, aggregating them in terms of collection, filtering them by timestamps calculation, and ordering them in terms of total transacted value.

One option to solve these complex data requirements is to build a server using an indexing framework. A blockchain indexer is an implementation of the push model of getting the data. Instead of actively pulling the data from the source, indexers listen to the stream of data from the blockchain, and the data can be immediately filtered and processed according to defined requirements. Indexers can also be used to simplify the "wide" query execution. For example, a data stream can be written to a permanent database for later data analysis using a convenient query language like SQL.

Building a server and indexing blockchain data on your own is not an easy task. The index server will be responsible for processing all the transactions and saving them to a database. Then you’ll need to build a set of APIs to get the data for your dApp. This option is resource intensive, requires maintenance, presents a single point of failure, and breaks important security properties required for decentralization.Also, specific Blockchain properties like finality, chain reorganizations, or empty blocks complicate this process further and make it not just time-consuming but conceptually hard to retrieve correct query results from blockchain data.

As an alternative, you can try one of the many available indexing services on the NEAR blockchain, and here is a suggestive decision tree of which tool to use for your data needs presented by Pagoda:

Data Platform Decision Tree

  • NEAR Indexer Framework: a micro-framework providing you with a "live" stream of blocks. Useful to handle on-chain real-time "events".
  • NEAR Indexer for Explorer: leverages the indexer micro-framework to watch and store all of the blockchain's events/data into a transactional PostgreSQL database. You can clone the GitHub repository and customize your own indexer solution.
  • NEAR Lake Framework: a companion library to NEAR Lake. It allows you to build your own indexer that watches a stream of blocks from a NEAR Lake data source and allows you to create your own logic to process that data. Keep in mind this is probably the one you want to use for future projects, instead of the Indexer Framework. Read why it is better.
  • NEAR Lake Indexer: leverages the indexer micro-framework to watch and store all of the blockchain's events/data as JSON files on a user-specified AWS S3 or S3-compatible storage.
  • Near Query API: Query API allows you to seamlessly create, manage, and discover indexers on NEAR. Developers can deploy their indexers to aggregate historical data in a matter of minutes, while accessing the data via custom GraphQL queries.
  • The Graph: The Graph gives developers tools to process blockchain events and make the resulting data easily available via a GraphQL API, known individually as a subgraph. Graph Node is now able to process NEAR events, which means that NEAR developers can now build subgraphs to index their smart contracts.
  • Pagoda API is a hosted service managed by Pagoda that solves the complex data problem by indexing the blockchain into datamarts and is accessible via standard RESTful APIs for you to directly use in any part of your application. The API enables performant and efficient querying of blockchain data without having to build and manage your own indexer infrastructure. Pagoda also offers the Indexer framework as a decentralized solution to indexing on-chain data, and a centralized Data Lake source that can be used to build your own indexers and servers for such data query needs.
  • PIKESPEAK API: an enterprise-grade API where you can fetch blockchain events and aggregated analytics on wallets, validators, delegators, money transfers, dapps activity and more. Documentation
  • Mintbase Indexer A highly efficient and adaptable indexing solution developed to capture, process, and store NFT events throughout the NEAR ecosystem. This indexer provides developers with a streamlined and well-structured data stream, making it an optimal choice for constructing data-centric applications in the NFT space. By systematically monitoring and indexing a wide array of NFT-related events across various platforms and projects on NEAR, the Mintbase Indexer offers developers the necessary tools and data access to build innovative and practical applications. Furthermore, the indexed data can be conveniently queried using GraphQL, allowing for flexible and efficient data retrieval tailored to specific developer needs. Documentation
  • SubQuery: SubQuery is a fast, flexible, and reliable open-source data indexer that provides you with custom APIs for your web3 project across NEAR and many other chains. NEAR developers will benefit from the superior SubQuery experience, including the open-source SDK, tools, documentation, and developer support that the SubQuery ecosystem provides. Additionally, NEAR is accommodated by SubQuery’s Managed Service, which provides enterprise-level infrastructure hosting.
Data on the Blockchain | NEAR Documentation (2024)

FAQs

What are blockchain documentation? ›

What are Blockchain Process Documentation Services? Blockchain process documentation services refer to a specialized category of professional offerings from technical writers designed to facilitate the comprehensive documentation of processes within blockchain-based systems.

Is data on the blockchain encrypted? ›

Confidentiality – Using encryption, the publicly accessible information on the blockchain is encrypted preventing anyone without the secret key from interpreting the information.

What types of data are on blockchain? ›

List of blockchain data types
#KeywordPossible values
1Boolean0 and 1
2ByteInteger from -128 to 127 inclusive
3IntInteger from -2,147,483,648 to 2,147,483,647 inclusive
4LongInteger from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 inclusive
2 more rows

What data is stored on the blockchain? ›

Such a record could be a list of transactions (such as with a cryptocurrency), but it is also possible for a non-public blockchain to hold a variety of other information like legal contracts, state identifications, or a company's inventory.

How data is written in blockchain? ›

📌 The answer is it's “append-only model", which means that once data is added to the blockchain, it cannot be altered or deleted. This immutability is achieved through advanced cryptographic techniques, such as hashing and digital signatures, which secure each block and ensure its integrity.

Can everyone see data on blockchain? ›

Blockchain data refers to the on-chain data or transactional information hosted on the blockchain network. It contains information from all entries in a complete blockchain, which is accessible to everyone. With the validation of new transactions, the blockchain continuously records transaction information.

Can blockchain data be hacked? ›

The concepts behind blockchain technology make it nearly impossible to hack into a blockchain. However, weaknesses outside of the blockchain create opportunities for thieves. Hackers can gain access to cryptocurrency owners' cryptocurrency wallets, exchange accounts, or the exchanges themselves.

Is data on blockchain private? ›

Blockchains like Bitcoin are also transparent and public. This means that the entire digital ledger is open to anyone who wants to go and have a look at it.

What are the 4 types of blockchain? ›

There are four main types of blockchain networks: public blockchains, private blockchains, consortium blockchains and hybrid blockchains. Let's explore each of these platforms and its benefits, drawbacks and ideal uses.

How to access blockchain data? ›

To retrieve all the data records from an account data storage, use GET /addresses/data/{address} method. To retrieve a data record by key, use GET /addresses/data/{address}/{key} method.

What is blockchain in simple words? ›

Blockchain is a shared, immutable ledger that facilitates the process of recording transactions and tracking assets in a business network. asset can be tangible (a house, car, cash, land) or intangible (intellectual property, patents, copyrights, branding).

What is the problem with data storage in blockchain? ›

High Data Volume

One of the challenges associated with data duplication in blockchain data warehousing arises from the redundant storage of information across nodes. As more transactions are executed on the network, more data is created, necessitating an increase in storage capacity.

What type of transaction cannot be stored in blocks on a blockchain? ›

A transaction that assigns copyright ownership to a song cannot be stored in blocks on block chain.

Is blockchain just a database? ›

While blockchains can be considered a database, a database is typically not a blockchain. Databases generally don't use signed blocks to store the data. The blockchain structure makes it virtually impossible for someone to change the data without breaking the chain.

What are blockchain proofs? ›

Proof of work is a concept used in some public blockchains to demonstrate that a program did the work required to propose a new block for the chain.

How are documents stored on blockchain? ›

The efficient way to store the information is by generating the cryptographic hash of the document and storing that on the blockchain with the timestamp. Hash values are much smaller as compared to their corresponding documents and save a huge amount of space and cost.

What are the types of records in blockchain? ›

A blockchain ledger consists of two types of records, individual transactions and blocks. The first block has a header and data that pertain to transactions taking place within a set time period. The block's timestamp is used to help create an alphanumeric string called a hash.

Top Articles
5 Blockchain Networks With Ridiculously Low Gas Fees
How to Create a Budget: 7 Steps to Follow
Jack Doherty Lpsg
Metra Union Pacific West Schedule
Restored Republic January 20 2023
Directions To Franklin Mills Mall
How Many Cc's Is A 96 Cubic Inch Engine
Jonathon Kinchen Net Worth
Costco The Dalles Or
When is streaming illegal? What you need to know about pirated content
Sam's Club Gas Price Hilliard
CA Kapil 🇦🇪 Talreja Dubai on LinkedIn: #businessethics #audit #pwc #evergrande #talrejaandtalreja #businesssetup…
Milk And Mocha GIFs | GIFDB.com
Sitcoms Online Message Board
10 Great Things You Might Know Troy McClure From | Topless Robot
zopiclon | Apotheek.nl
Blue Beetle Showtimes Near Regal Swamp Fox
Animal Eye Clinic Huntersville Nc
Bcbs Prefix List Phone Numbers
Water Days For Modesto Ca
Zack Fairhurst Snapchat
Theater X Orange Heights Florida
Sussyclassroom
Woodmont Place At Palmer Resident Portal
Best Nail Salons Open Near Me
Cain Toyota Vehicles
How to Make Ghee - How We Flourish
Netwerk van %naam%, analyse van %nb_relaties% relaties
Delectable Birthday Dyes
WRMJ.COM
Best Town Hall 11
Jesus Calling Feb 13
*!Good Night (2024) 𝙵ull𝙼ovie Downl𝚘ad Fr𝚎e 1080𝚙, 720𝚙, 480𝚙 H𝙳 HI𝙽DI Dub𝚋ed Fil𝙼yz𝚒lla Isaidub
Korg Forums :: View topic
Otis Inmate Locator
What Time Does Walmart Auto Center Open
Weekly Math Review Q4 3
Omnistorm Necro Diablo 4
Edict Of Force Poe
Empire Visionworks The Crossings Clifton Park Photos
SF bay area cars & trucks "chevrolet 50" - craigslist
Ashoke K Maitra. Adviser to CMD's. Received Lifetime Achievement Award in HRD on LinkedIn: #hr #hrd #coaching #mentoring #career #jobs #mba #mbafreshers #sales…
Trap Candy Strain Leafly
How To Upgrade Stamina In Blox Fruits
Yakini Q Sj Photos
What to Do at The 2024 Charlotte International Arts Festival | Queen City Nerve
2013 Honda Odyssey Serpentine Belt Diagram
Holzer Athena Portal
Hdmovie2 Sbs
Understanding & Applying Carroll's Pyramid of Corporate Social Responsibility
M Life Insider
Inside the Bestselling Medical Mystery 'Hidden Valley Road'
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 5854

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.