NEAR Lake indexer basic tutorial
frolvanya/near-lake-raw-printer
: source code for the tutorial on how to create an indexer that prints block height and number of shards
Recently we have published a Python version of the NEAR Lake Framework on pypi.org
We want to empower you with a basic tutorial on how to use the Python Package. Let's get started!
Create a project
Create an indexer project:
mkdir near-lake-raw-printer && cd near-lake-raw-printer
touch main.py
Install dependencies
Install near-lake-framework
pip3 install near-lake-framework
Import near-lake-framework
In the main.py
file let's import the necessary dependencies:
from near_lake_framework import near_primitives, LakeConfig, streamer
We've imported the main function streamer
which will be called to actually run the indexer, near_primitives
and LakeConfig
type we need to contruct.
Create a config
Add the instantiation of LakeConfig
below:
config = LakeConfig.mainnet()
config.start_block_height = 69030747
config.aws_access_key_id = os.getenv("AWS_ACCESS_KEY_ID")
config.aws_secret_key = os.getenv("AWS_SECRET_ACCESS_KEY")
Just a few words on the config, function mainnet()
has set s3_bucket_name
, s3_region_name
for mainnet.
You can go to NEAR Explorer and get the most recent block height to set config.start_block_height
.