Skip to main content

· 3 min read

Blockchains excel at decentralizing data and continue to revolutionize traditional systems of trust and record-keeping, but data retrieval is often inefficient and majorly time-consuming for developers hampering the overall development experience.

Indexers like Envio allow developers to sift through blockchain data, tidy it up, and store it in a useful intermediary format that is easily accessible. Applications can then use this format for potent queries on indexed data, ensuring scalability and production readiness.

This tutorial will take you through a step by step guide to indexing a Greeter smart contract deployed on Linea using Envio.

Background​

Greeter contract​

The Greeter contract is a very simple smart contract that allows a user to write a greeting message on the blockchain.

Envio​

Envio is a real-time indexer built specifically for EVM-compatible blockchains, providing developers with a seamless and efficient indexing solution. Designed to optimize the user experience, Envio offers automatic code generation and flexible language support. Indexers on Envio can be written in JavaScript, TypeScript or ReScript. Easily aggregate blockchain data into a graphQL query-able database.

Prerequisites​

Environment tooling​

  1. Node.js we recommend using something like fnm or nvm to install Node
  2. pnpm
  3. Docker Desktop

Install Envio​

npm i -g envio

Step by step instructions​

Initialize the project​

Initialize the project using the Greeter template.

Run

envio init

Name your indexer

? Name your indexer:

Choose the directory where you would like to setup your project (default is the current directory)

? Set the directory:  (.) .

Select to start from a template

? Would you like to start from a template or migrate from a subgraph?
> "Template"
"SubgraphMigration"
[↑↓ to move, enter to select, type to filter]

Choose Greeter when prompted to choose template.

? Which template would you like to use?
"Blank"
> "Greeter"
"ERC-20"
[↑↓ to move, enter to select, type to filter]

Then choose a language of your choice for the event handlers.

? Which language would you like to use?
> "Javascript"
"Typescript"
"Rescript"
[↑↓ to move, enter to select, type to filter]

Start the indexer​

Dev note: 📢 make sure you have docker open

The following commands will start the docker and create databases for indexing data, make sure to re-run dev if you make changes to the files

Run

envio dev

The indexer will then start indexing the contract's specified in the config.yaml file from the start_block specified.

Write to the contract on Lineascan​

Once the indexer is running, you can call functions on the Greeter contract that is deployed on Linea.

Navigate to the contract on Lineascan and call the setGreeting function.

View the indexed results​

You can view the indexed results on your local Hasura server.

open http://localhost:8080

The hasura admin-secret is testing and the tables can be viewed in the data tab or queried from the playground


Check out the full Envio docs here.

Our engineers are available to help you with your indexing use case and where Envio can provide value. Hop into our Discord or send us an email at hello@envio.dev.

· 4 min read

The rising demand for NFTs has put a spotlight on the need for effective tools to track their creation, movement, and trading activities. For businesses and developers working with NFTs, the ability to monitor minting events is crucial, especially with the growth of NFT based applications that Linea will enable thanks to its scaling abilities.

This article explains how you can use Hal Stream to track NFT minting on Linea.

Table of Contents:

  1. Importance of Tracking NFT Minting
  2. Understanding Hal Stream
  3. How to Use Hal Stream on Linea to Track NFT Minting
  4. Applications of Hal Stream for NFTs on Linea
  5. Conclusion

1. Importance of Tracking NFT Minting​

Tracking the creation or "minting" of NFTs provides valuable insights into the dynamics of the NFT market. Developers need this data to manage NFT applications, update their backend, follow trends, identify new opportunities, or simply do some analysis.

2. Understanding Hal Stream​

Hal Stream is a powerful tool that allows developers to monitor blockchain data from specific contracts, wallets, or NFT collections. With Hal Stream, you can filter and query data based on specific conditions, all through a single REST API. The best part is that it requires no coding and supports multiple EVM-compatible blockchains including Linea.

3. How to Use Hal Stream on Linea to Track NFT Minting​

Because Linea is a zkEVM, it behaves the same way as any other EVM chains as far as setting up Hal Stream is concerned, enabling you to setup your monitoring with no friction while benefit from Linea’s fast and scalable throughput.

To use Hal Stream to monitor NFT minting on Linea, follow these steps: First, create a Blueprint by logging into your Hal account. Select "Contract Events ».

Data source selection

Next, enter the contract address of the NFT you want to monitor. Make sure this is a Linea NFT contract, in this example we’ll be using a test collection that we created using NFTS2ME.

Contract address

After adding the contract address, click "Continue". You will have the option to filter event data. To track NFT minting, you want to monitor the 'transfer' event, and more specifically, with the 0X0000… address in the ‘from’ field (as per the ERC-721 standard). To do this, select the event from the event list and click "Add filter" to specify the ‘from’ address.

Filtering

Finally, give your stream a name, then "Save and Deploy". Now, whenever an NFT is minted from the monitored contract, Hal Streams will capture the event data and make it accessible through a REST API using your API key. In your dashboard, you can see the stream alongside all the events that have been added to it, and an easy way for me to consume it.

Consume Hal Stream

When consuming this API, Hal stream will return a list of events that matched your filtering.

Example Stream output

If pulling the data from the API isn’t what’s best in your workflow, connectors will help Hal Stream push to your system directly, whether it’s using webhook, SQS or databases.

Connectors

4. Applications of Hal Stream for NFTs on Linea​

Tracking NFT minting can be applied in various scenarios. And with Linea’s scalability, it can go further than collectible and step into gaming for example, where developers need to identify the newly minted NFTs owned by each player. With Hal Stream, they can easily correlate the NFT minting event to a user's wallet and update their in-game inventory accordingly. In a real estate application, developers can use Hal Stream to monitor the minting of property NFTs, providing a transparent and secure way of managing property ownership and transfers.

5. Conclusion​

Tracking NFT minting is essential for businesses and developers in the NFT space. With Hal Stream, monitoring these minting events on Linea becomes a breeze. Start tracking NFT minting on Linea with Hal Stream today, and unlock the valuable insights you need to thrive in the NFT market.

· One min read

We're excited to share the great educational content the Linea community has been putting out! So, we're dedicating a whole portion of our docs website to featuring community tutorials!