Envio Developer Update | April 2024

Developer Update | April 2024

Welcome to the latest developer update of April 2024.  Dive into our latest release V.0.0.40 and see what the Envio team has been shipping over the past month including new features and technical updates, upcoming events, developer tutorials and much more. 🚢

🚀 New Release: Version 0.0.40 Now Available! 🚀

  • New Feature: Add custom indices to your database. (See the guide below)

  • New Feature: Reference your generated code as a package in your handlers. (See the guide below)

  • Our fast Hypersync Client Event Decoder now handles string types in events and will be the default event decoder used by the indexer. (To use Viem instead, you can set event_decoder: viem in your config.yaml file.)

  • Fix: Failures on DB migrations now exit with failure code 1.

Envio HyperSync Expands Support on the Fuel Network 🤝 

In addition, we’re excited to announce that Envio has recently fully integrated its Hypersync service on the Fuel Network, a Rollup Operating System purpose-built for Ethereum. Envio’s data infrastructure serves as an accelerated data query layer on top of the Fuel network allowing application developers and data analysts to easily parse, query, and analyse large datasets on Fuel within seconds! ⚡

Check out Spark Finance, the world's fastest on-chain order book built on Fuel VM, is a great case study for utilising Hypersync to present near-instant access to order book information to their traders. 

Learn more here.

New HyperSync Network Support ⚡

We’re excited to announce that Envio HyperSync has expanded enhanced indexing support for developers building on Polygon’s Amoy Testnet.

To see the full list of currently supported chains on HyperSync visit our docs

Create Custom Indices

Our new exciting feature allows developers to refine an entity and use the “@index directive on fields they wish to add an index to.

type MyEntity {
 id: ID!,
 userAddress: String! @index
 tokenAddress: String! @index
}

The fields marked with “@index will now create indices in your database, making querying on these fields much faster. 

You can also group fields into one composite index like this:

type MyEntity @index(fields: ["userAddress", "tokenAddress"]) {
 id: ID!,
 userAddress: String!
 tokenAddress: String!
}

This will then create a composite index on both of these fields.

Note: All “id” fields and "@derivedFrom" fields automatically have indices, so there is no need to add a custom index.

Reference Generated Code As a Package

⭐Note: This is optional and you should be able to continue referencing your generated files as before with no changes.

Previously, you would have to reference the file that gives you handlers and types in your generated folder like this:

import { ERC20Contract } from "../generated/src/Handlers.gen";

import { AccountEntity } from "../generated/src/Types.gen";

ERC20Contract.Transfer.handler(({ event, context }) => {...

Now you can add your generated code as an optional dependency in your project's package.json like this:

{
  //... rest of package.json configuration,
 "optionalDependencies": {
 "generated": "./generated"
  }
}

From there you can simply reference the functions and types like this:

import { ERC20Contract, AccountEntity } from "generated";

ERC20Contract.Transfer.handler(({ event, context }) => {...

For handler unit tests, simply import TestHelpers:

import assert from "assert";
import { TestHelpers, AccountEntity } from "generated";
const { MockDb, ERC20, Addresses } = TestHelpers;

describe("Transfers", () => {
 it("Transfer subtracts the from account balance and adds to the to account balance", () => {
 //Instantiate a mock DB
    const mockDbEmpty = MockDb.createMockDb();

 //Get mock addresses from helpers
    const userAddress1 = Addresses.mockAddresses[0];
    const userAddress2 = Addresses.mockAddresses[1];

 //Make a mock entity to set the initial state of the mock db
    const mockAccountEntity: AccountEntity = {
 id: userAddress1,
      balance: 5n,
    };

DappCon 2024 Sponsors 💫 

Incredibly excited to announce that Envio has been listed as one of the many proud sponsors of DappCon 2024! Hosted by Gnosis in Berlin, DappCon is an awesome developer conference for Ethereum infrastructure and dApps and a great chance to get your project recognised and to learn from the very best, all while soaking in Berlin’s eclectic atmosphere. 

Get your ticket here.

Upcoming Events 🗓️

Developer Workshops 🧑‍💻

Developer Tutorials 🍎 

Written Tutorials: 

For a full list of written tutorials visit our docs.

Envio 101 Video Tutorials:

For a full list of our video tutorials visit our YouTube

Playlist of the month

Ship with us. 🚢

Envio is a modern, multi-chain EVM blockchain indexing framework speed-optimized for querying real-time and historical data.

If you're a blockchain developer looking to enhance your development process and unlock the true potential of Web3 infrastructure, look no further. Join our growing community of elite developers, check out our docs, and let's work together to revolutionise the blockchain world and propel your project to the next level.

Stay tuned for more monthly updates by subscribing to our newsletter, following us on X or hopping into our Discord for more up-to-date information.