The Graph
Published in

The Graph

September Development Update

Issue 02 / September 2018

Last month, we attended ETHBerlin and sponsored bounties for hackers to build on The Graph. After returning from the event, we decided to improve the developer experience further, focusing on stabilization and reliability. The next hackathon, ETHSanFrancisco, is coming up this weekend and we’re excited to have significant improvements ready for the community to play with. It has been a busy month!

New Features

Block and event stream

This feature plays a crucial role in helping The Graph reliably fetch data from Ethereum and make it available to subgraph mappings, without skipping a beat — or block, rather. There are two sides to this: one is to ensure Ethereum blocks, transactions, and events are being fetched and cached as the chain evolves, without gaps and as fast as possible. The other side is to provide each subgraph with a resumable stream of blocks, events and transactions so that subgraph creators can be certain that everything is processed in a predictable and deterministic order.

Explicit imports & AssemblyScript packages

Until recently, subgraph mappings were compiled by injecting a set of global APIs such as store and Entity into the mapping sources prior to passing them on to the AssemblyScript compiler. We have now switched to using explicit imports, allowing developers to choose which APIs they would like to use. All our AssemblyScript code has moved to the @graphprotocol/graph-ts package. This avoids naming conflicts in the global scope and provides a familiar way of importing other modules. It also enables installing and importing external AssemblyScript-compatible packages. An example of explicit imports:

import { Entity, store } from '@graphprotocol/graph-ts'
import { SomeEvent, Contract } from './types/MyDataSource/Contract'
function handleSomeEvent(event: SomeEvent): void {
let entity = new Entity()
let contract = Contract.bind(event.address)
store.set('MyEntity', 'some-id', entity)


Previously, it was only possible to push entity updates to the store using store.set() and store.remove(). In order to load existing entities and change them in mappings, we have added store.get('EntityType', 'id'). This is particularly useful if entities store a list of values—such as reference IDs—and an event handler needs to remove or add values from or to such a list.

Other improvements

When starting up a Graph Node, we now detect if it uses an incompatible Ethereum network under the same name—e.g. mainnet. This avoids confusion and unexpected behavior. We’ve added other fixes as well for error handling when connecting to IPFS and Ethereum.

The block hash parameter was removed fromSmartContract.bind(address) in @graphprotocol/graph-ts since the block hash is already known outside the mapping context.

A crypto module was added to @graphprotocol/graph-ts, providing the KECCAK-256 algorithm. It can be imported and used with

import { crypto } from '@graphprotocol/graph-ts'
let hash = crypto.keccak256(someBytesArray)
entity.setBytes('someHash', hash)

We have written an end-to-end example dApp, including an ERC-721 token and auction smart contract, a subgraph and a React app: it was conceived at ETHBerlin and is called BitSausage.

What’s next?

We’ll be at ETHSanFrancisco from October 5th–7th. After this, our focus will be working towards a hosted service for dApp developers building on The Graph.

A couple of features that we may get in before the weekend include allowing mappings to access block and transaction data associated with events, code generation for GraphQL schema types as well as a subgraph overview page.

Get Involved

Would you like to get involved in developing The Graph? We’ve begun identifying easy starting points for new contributors: good first issues in Graph Node, good first issues in Graph CLI. We will add more soon.

We always appreciate feedback about The Graph. Don’t be afraid to file issues against Graph Node, Graph CLI or Graph TypeScript.

Have questions or want to chat with the team? Come join our Discord!

If you’re excited about The Graph and would like to explore a position on the team, take a look at our careers page.

Happy Hacking!

— Jannis & The Graph Protocol Team ✌

Follow The Graph on Twitter

Join us on Discord

Join our Telegram group

Subscribe to The Graph’s subreddit

We’re hiring!

The Graph is a query protocol for blockchain data using GraphQL.

Recommended from Medium

What is cloud computing?

Major developers reply on these popular platforms including AWS Lambda, Google App Engine

web3j-4.1.1 is available


7 Reasons You Should Try Go

Merge k Sorted Lists

How To Prepare For AWS Certified Advanced Networking — Specialty

How To Prepare For AWS Certified Advanced Networking — Specialty

In Boilerplates We Trust

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jannis Pohlmann

Jannis Pohlmann

Tech Lead at Edge & Node, Co-Founder of The Graph

More from Medium

Moralis Launches Support for Magic

Gaming Lifehack: How to integrate an ERC-20 into the ChainSafe Gaming SDK

Announcing Our Seed Investment in Suborbital

Custom Super Tokens