Envio 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 guide below)
- New Feature: Reference your generated code as a package in your handlers. (See 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.
⭐Note: This list is for Hypersync-supported networks only. Envio’s HyperIndex, as the indexing framework, supports any EVM network using RPC. If you would like Hypersync added to a network we don’t support, just let us know!
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,
};