Using NEAR Lake Framework, we can subscribe to the stream of blocks from the NEAR Lake data source. The source of data are JSON files stored in an AWS S3 bucket by NEAR Lake Indexer. The NEAR Lake Framework takes care of downloading and parsing the data for users, but the reader is paying the costs. More details about technical limitations and estimating costs can be found here.
Initialization
Letβs start by initializing the NEAR Lake Framework.AWS Credentials
To access the data provided by NEAR Lake you need to provide valid AWS credentials in order to be charged by the AWS for the S3 usage.AWS credentialsPlease note that using your own AWS Credentials is the only way to access the data provided by NEAR Lake ecosystem.
Lake Configuration
To initialize the NEAR Lake Framework, we need to provide the following basic settings:- The S3 bucket name: the bucket where the NEAR Lake data is stored. The value is
near-lake-data-testnetfor the testnet andnear-lake-data-mainnetfor the mainnet. - The S3 region: The AWS region where the S3 bucket is located. The default value is
eu-central-1. - Start block height: The block height from which the indexer will start processing blocks.
- π¦ Rust
- π JavaScript
- π Python
The Rust package provides a way to use the default configuration for testnet/mainnet and requires only to choose network and set the start block height which in the example we pass as command line argument.
Running the Indexer
To run the indexer, we need to create a function that will handle every message from the stream. In this function, we can access the block data and process it as needed.- π¦ Rust
- π JavaScript
- π Python
Parsing the Block Data
From the block data, we can access the transactions, their receipts and actions. In this example, we will look for FunctionCall actions on a specific contract and log the details of each call.- π¦ Rust
- π JavaScript
- π Python
Versioning for this articleAt the time of this writing, this example works with the following versions:
- near-lake-framework (Rust):
0.7.13 - @near-lake/framework (JS):
0.1.5 - near-lake-framework (Python):
0.1.3 - rustc:
1.86.0 - node:
22.18.0 - python:
3.13.5