Skip to content
by Unity Nodes
NEAR Protocol

NEAR Lake Framework Tutorial

about 6:10 long

Nothing is loaded from YouTube until you press play, and then without tracking cookies.

About this video

NEAR Lake Framework is a brand new word in indexer building approach and this tutorial is going to walk you through easy steps to use the NEAR Lake Framework and NEAR Lake to setup your own indexer easily on NEAR.

Relevant Links of the project: NEAR Lake Framework official repo: https://github.com/near/near-lake-fra... NEAR Lake indexer repo: github.com/near/near-lake Simple example of a data printer built on top of NEAR Lake Framework: https://github.com/near/near-lake-raw... Another simple example of the indexer built on top of NEAR Lake Framework for a tutorial purpose: https://github.com/near-examples/near... “nearprotocol” StackOverflow": https://stackoverflow.com/questions/t... Subscribe to our Pagoda Dev Newsletter to keep up with the most recent product updates! : eepurl.com/hYlQOj

Follow the latest from NEAR Protocol on: Website: near.org Discord: near.chat Blog: near.org/blog Twitter:   / nearprotocol   GitHub: github.com/near github.com/nearprotocol #Blockchain #FutureIsNEAR #NEAR #nearprotocol #indexer

Transcript

757 words

Captions as YouTube publishes them, usually machine-generated, so product and people names can be misheard.

  1. 0:02

    data platform team salutes you in this video i'm gonna show you how to use near lake framework to quickly build an indexer let's have an overview look at what we're building today we will create an indexer that will watch for the changes in a specified account or a list of accounts and will pre-end those changes in the terminal window nothing complex yet useful first of all we will design the command line interface for our application we want to pass key accounts which will take an account name we would like to

  2. 0:42

    pass multiple of them to provide a list of account names then we need to provide the block height to start indexing from and finally pass the chain id of course the design might be better but i found the proposed one as one of the shortest to implement for a tutorial moving on to the code at last let's create a project let's add all the dependencies we need in the real world we don't always know the full list of dependencies in the beginning but it is a tutorial and we

  3. 1:19

    are cheating a little bit once cargitomel is filled we can move on to the next phase we are starting with implementing a command line interface design we have created earlier important libraries we will be using defining the structure for command line arguments we are going to receive in our application defining the main function first of all we make it asynchronous we're using tokyo around time in the beginning we're reading the arguments passed to the

  4. 1:50

    application it is time to set up the near lake framework stream you can consider this code as a boilerplate instantiating the structure leak config converting the received arguments into the proper config parameters initiating the new leak framework stream we create a busy loop that is going to receive a streamer message from the framework and pass it to an unsynchronous function called handle streamer message we're going to create it later before proceeding with the creating a

  5. 2:22

    handler function we need to temporarily switch our focus and have a closer look at the structure streamer message we're receiving we want to figure out what we are looking for in our application the structure streamer message artificially represents the entire block of the near blockchain it includes everything that appeared in the block including the local receipts that are not available through the json rpc in this tutorial we are interested in state changes that can be found in a shard

  6. 2:55

    state changes structure is an alias to a vector of state change with cos u which in turn consists of two fields the calls and the value the value is a quite big numb with a number of variants the most important thing for us right now is that every variant has a field called the count id and this account id means the account was affected by this state change record now we're creating a function candle streamer message that receives the streamer message from the near lake framework and our list of watched

  7. 3:30

    account names so we know what we are looking for in each block we are making a separate function to check if the state change affects any of the accounts we are watching now we can finish the handler function if the check function returns true we print the message that contains the block height where the change appeared and the type of the change and just for the sake will print the entire state

  8. 4:20

    change record affecting the account and looks like we have finished it is time to run the application to ensure that it works and the easiest way to trigger the state change is to send some years to the account we are watching or from it we need aws credentials in order to connect to the near lake framework s3 bucket generating the credentials storing them in the home folder and moving on to a new world

  9. 4:59

    for the demo purpose i'm going to create a testnet account via near wallet let's go to the new explorer to get the fresh test net block height now we can transfer some mirrors from our testnet account to trigger the stage and now we can run our application to see everything is working and that's all folks the source code for this tutorial is available on github you can find the link below in the description thanks for your attention

  10. 6:10

    you