NEAR Lake deprecated as of March 24, 2026. This page uses the NEAR Lake Framework, which reads from AWS S3 buckets that have stopped indexing new blocks. For new projects, use Neardata (direct replacement), Data APIs, Goldsky, or the Nearcore Indexer.
nft_mint events and print relevant data about newly minted NFTs.
The indexer is watching for nft_mint Events and prints some relevant data:
receiptIdof theReceiptwhere the mint has happened- Marketplace
- NFT owner account name
- Links to the NFTs on the marketplaces
near-examples/near-lake-nft-indexer
Source code for the tutorial
near-examples/near-lake-nft-indexer: source code for this tutorialMotivation
NEAR Protocol had introduced a nice feature Events. The Events allow a contract developer to add standardized logs to theExecutionOutcomes thus allowing themselves or other developers to read those logs in more convenient manner via API or indexers.
The Events have a field standard which aligns with NEPs. In this tutorial we’ll be talking about NEP-171 Non-Fungible Token standard.
In this tutorial our goal is to show you how you can “listen” to the Events contracts emit and how you can benefit from them.
As the example we will be building an indexer that watches all the NFTs minted following the NEP-171 Events standard, assuming we’re collectors who don’t want to miss a thing. Our indexer should notice every single NFT minted and give us a basic set of data like: in what Receipt it was minted, and show us the link to a marketplace (we’ll cover Paras and Bitte/Mintbase in our example).
We will use JS version of NEAR Lake Framework in this tutorial. Though the concept is the same for Rust, but we want to show more people that it’s not that complex to build your own indexer.
Preparation
CredentialsPlease, ensure you’ve the credentials set up as described in the development environment setup. Otherwise you won’t be able to get the code working.
package.json
package.json
typescript as a dev dependency. Let’s configure the TypeScript. We’ll need to create tsconfig.json file for that
tsconfig.json
index.ts in the project root and thus finish the preparations.
Set up NEAR Lake Framework
In theindex.ts let’s import startStream function and types from near-lake-framework:
index.ts
LakeConfig below:
index.js
s3BucketName for mainnet, default s3RegionName and a fresh-ish block height for startBlockHeight. You can go to NEAR Explorer and get the freshest block height for your setup. Though you can use the same as we do.
Now we need to create a callback function that we’ll be called to handle StreamerMessage our indexer receives.
index.ts
Callback function requirementsIn
near-lake-framework JS library the handler have to be presented as a callback function. This function have to:- be asynchronous
- accept an argument of type
StreamerMessage - return nothing (
void)
index.ts
index.ts
index.ts at this moment should look like the following:
index.ts
Events and where to catch them
First of all let’s find out where we can catch the Events. We hope you are familiar with how the Data Flow in NEAR Blockchain, but let’s revise our knowledge:- Mint an NFT is an action in an NFT contract (doesn’t matter which one)
- Actions are located in a
Receipt - A result of the Receipt execution is
ExecutionOutcome ExecutionOutcomein turn, catches the logs a contract “prints”- Events built on top of the logs
StreamerMessage brings us.
Also, we need to define an interface to catch the Events. Let’s copy the interface definition from the Events Nomicon page and paste it before the handleStreamerMessage function.
index.ts
Catching only the data we need
Inside the callback functionhandleStreamerMessage we’ve prepared in the Preparation section let’s start filtering the data we need:
index.ts
Shards and collected the lists of all ExecutionOutcomes into a single list (in our case we don’t care on which Shard did the mint happen)
Now we want to deal only with those ExecutionOutcomes that contain logs of Events format. Such logs start with EVENT_JSON: according to the Events docs.
Also, we don’t require all the data from ExecutionOutcome, let’s handle it:
index.ts
- We are walking through the ExecutionOutcomes
- We are constructing a list of objects containing
receipt(it’s id and the receiver) andeventscontaining the Events - In order to collect the Events we are iterating through the ExecutionOutcome’s logs trying to parse Event using regular expression. We’re returning
undefinedif we fail to parseEventLogData - Finally once
eventslist is collected we’re filtering it dropping theundefined
EventLogData.
The goal for our indexer is to return the useful data about a minted NFT that follows NEP-171 standard. We need to drop irrelevant standard Events:
index.ts
Almost done
So far we have collected everything we need corresponding to our requirements. We can print everything in the end of thehandleStreamerMessage:
index.ts
handleStreamerMessage function:
index.ts
nft_mint event and print the data in the terminal.
Having troubles running the indexer? Please, check you haven’t skipped the development environment setup part :)
Crafting links to Paras and Mintbase for NFTs minted there
At this moment we have an array of objects we’ve crafted on the fly that exposes receipt, execution status and event logs. We definitely know that all the data we have at this moment are relevant for us, and we want to extend it with the links to that minted NFTs at least for those marketplaces we know. We know and love Paras and Mintbase.Paras token URL
We did the research for you and here’s how the URL to token on Paras is crafting:- [1] - Paras contract address (
x.paras.near) - [2] - First part of the
token_id(EventLogData.datafor Paras is an array of objects withtoken_idskey in it. Those IDs represented by numbers with column:between them) - [3] -
token_iditself
interface EventLogData:
Mintbase token URL
And again we did the research for you:- [1] -
meta_id(EventLogData.datafor Mintbase is an array of stringified JSON that containsmeta_id) - [2] - Store contract account address (basically Receipt’s receiver ID)
interface EventLogData:
.map(), but it might be too much. So let’s proceed with a forloop to craft the output data we want to print.
index.ts
index.ts
.paras.near (e.g. x.paras.near) we assume it’s from Paras marketplace, so we are changing the corresponding variable.
After that we iterate over the Events and its data using the ParasEventLogData we’ve defined earlier. Collecting a list of objects with the NFTs owner and NFTs links.
Mintbase turn, we hope Nate and his team have migrated to NEAR Lake Framework already, saying “Hi!” and crafting the link:
index.ts
.mintbaseN.near where N is number (e.g. nate.mintbase1.near).
After we have defined that the ExecutionOutcome receiver is from Mintbase we are doing the same stuff as with Paras:
- Changing the
marketplacevariable - Collecting the list of NFTs with owner and crafted links
index.ts
output
index.ts
index.ts
index.ts
handleStreamerMessage function
index.ts
output.push() expression:
index.ts
Having troubles running the indexer? Please, check you haven’t skipped the development environment setup part :)
Conclusion
What a ride, yeah? Let’s sum up what we have done:- You’ve learnt about Events
- Now you understand how to follow for the Events
- Knowing the fact that as a contract developer you can use Events and emit your own events, now you know how to create an indexer that follows those Events
- We’ve had a closer look at NFT minting process, you can experiment further and find out how to follow
nft_transferEvents
Source code for the tutorial
near-examples/near-lake-nft-indexer: source code for this tutorial