msfew

Posted on Jan 08, 2024Read on Mirror.xyz

ZK Indexer for Inscriptions, and Other Ecosystem zkGraphs

TL;DR

  • Inscriptions, as a new popular asset standard, caused huge gas spikes and performed stress test by spamming for different blockchains. Inscriptions are even spread to Web2 websites such as GitHub and LinkedIn.

  • Currently, the model of Ethereum inscriptions is broken because the dominant inscriptions protocol, Ethscriptions, is running close sourced and centralized indexer.

  • We built a Ethscriptions indexer with zkOracle and zkGraph. It can index and access Ethscriptions transactions in a decentralized, trustless and verifiable way.

  • We also covered other HyperOracle ecosystem zkGraphs: Proof of Membership, Proof of Blacklisted, Proof of Ownership.

0. Intro to zkGraph

HyperOracle is a programmable zkOracle protocol. For more information about what we are building, check out our litepaper.

zkOracle provides expansive compute for smart contracts. To program a zkOracle, you can write code in a zkGraph (a piece of code for custom logic) to define your own “API”.

As a program for the zkOracle, developers can write a zkGraph to access historical data from a blockchain directly inside a smart contract and perform complex compute in a trustless and secure way.

TL;DR

  • Inscriptions, as a new popular asset standard, caused huge gas spikes and performed stress test by spamming different blockchains. Inscriptions have even spread to Web2 websites such as GitHub and LinkedIn.

  • Currently, the model for Ethereum inscriptions is broken because the dominant inscriptions protocol, Ethscriptions, is running a close sourced and centralized indexer.

  • We built a Ethscriptions indexer with zkOracle and zkGraph. It can index and access Ethscriptions transactions in a decentralized, trustless and verifiable way.

  • We also cover other HyperOracle ecosystem zkGraphs in this blog post: Proof of Membership, Proof of Blacklisted, Proof of Ownership.

0. Intro to zkGraph

HyperOracle is a programmable zkOracle protocol. For more information about what we are building, check out our litepaper.

zkOracle provides expansive compute for smart contracts. To program a zkOracle, you can write code in a zkGraph (a piece of code for custom logic) to define your own “API”.

As a program for the zkOracle, developers can write a zkGraph to access historical data from a blockchain directly inside a smart contract and perform complex compute in a trustless and secure way.

1. Intro to Ethscriptions

a) Ordinal, Inscriptions, Ethscriptions

The concept of Inscriptions started with Bitcoin's Ordinals. Ordinals introduced a way to inscribe data directly on Bitcoin, called Inscriptions. It makes NFT and other tokens possible on Bitcoin, even with Bitcoin’s limited programmability (no smart contract on Bitcoin).

Now people are doing Inscriptions on networks other than Bitcoin. On Ethereum, people have adopted Ethscriptions. It uses transaction data to create Inscriptions tokens.

But why do they use Ethscriptions if Ethereum already has NFT such as ERC-721?

Well it is a new (hyped) way for NFT. And it does have advantages such as fully onchain token and cheaper operation cost. And if you really think about it, Inscriptions are actually one Layer2, a based sovereign rollup (onchain data availability and consensus, offchain execution and settlement), but without the scaling effect because its TPS is equal to Ethereum’s.

b) How Ethscriptions Work

Here’s an explanation by jtriley.eth:

create: transfer zero wei to yourself where the calldata is the inscription data (jpg, gif, txt, etc)

transfer: transfer zero wei to yourself where the calldata is the tx hash of the inscription creation tx

there’s also a way to do it w a smart contract w events based on the “ethscription improvement proposals”

&& there’s also an offchain vm that interprets calldata sent to a designated address as tx data for its own execution environment. basically a sovereign rollup without the scalability (though i would avoid this for now, poor security assumptions)

You can read more at Ethscriptions’ doc.

For Ethscriptions creation, there’s an alternative way. ESIP-3 enabled Ethscriptions creation from smart contract’s event. You can use any smart contract that emits ethscriptions_protocol_CreateEthscription to create Ethscriptions assets. The benefits are: 1) larger data size (now your fully onchain can be up to 30MB theoretically), 2) smart contracts’ flexibility and computation (now you can use smart contract to better handle Ethscriptions, just like ERC-721 NFT).

To recap, we can use the following ways to create a Ethscriptions asset:

  • Send a transfer ETH transaction to yourself where the calldata is inscription data (jpg, gif…)

  • Emit a specific event from smart contract where the event data contains inscription data (jpg, gif…)

2. zkEthscription: Inscriptions Indexer with zkGraph

a) Introduction

Due to Ethscriptions’ model, reading Ethscriptions’ data is impossible onchain.

Importantly, this means:

  • No other smart contracts can read it (both tx calldata and event data)

  • No application can read it directly from the chain

Ethscriptions, of course, provided the official indexer, but it is a close sourced and centralized one. You will have to optimistically assumes everything is honest and leave it to the indexer to reject invalid "transactions".

We have seen the trend of decentralized indexer for Ordinals. We can also build one for Ethereum and Ethscriptions.

The difficulty is that onchain smart contract cannot access those Ethscriptions data, and this requires an offchain indexer.

We build zkEthscription, Ethscriptions Indexer with zkGraph. It leverages the trustless historical data access of HyperOracle zkOracle and programmability of zkGraph.

With zkEthscription, you can index Ethscriptions assets. Plus, zk proofs for those data access and indexing computation will be generated. This represents onchain verifiability, trustlessness, and decentralization.

b) Advantages and Use Cases

The advantages of zkEthscription are:

  • Verifiability: All data access and indexing computation can be verified onchain with the generated zk proof.

  • Modularity: With the programmability of zkGraph, it is super easy to support new ESIP of Ethscriptions and add new features to this indexer.

  • Ready in minutes: Building such an indexer only takes minutes with the support of historical data access and compute by HyperOracle zkOracle.

Some potential use cases enabled by zkEthscriptions are:

  • Onchain Ethscriptions Indexer: Since all computations are onchain verifiable, what we've built is actually not just an indexer, but an offchain component that is secure just like onchain smart contracts.

  • Mapping of Inscriptions: Since zk proof can be verified on any blockchain, the data of Ethscriptions can be cross-chained to other networks, thus enabling a mapping. This may solve some of the network congestion problems.

c) Future Upgrades

zkEthscriptions is just a prototype we built during the new year holiday. We'd love to see developers continue hacking on it.

  • Complete Ethscriptions and ESIP features: Currently, zkEthscription only supports ESIP-3 operations, for other operations, you can extend the existing format.

  • Expand to Bitcoin Inscriptions: Currently zkOracle supports Ethereum storage and event data access. You can support the original Inscriptions on Bitcoin by adding a new data source to zkEthscription via the DSP.

  • Make it a based zk rollup: The zk indexer we built is kinda like a zk rollup without the scaling part. You can tweak it to parse onchain data, perform complex computations, and bundle multiple transactions onchain, to make it an actual based zk rollup.

  • Full Indexer: Right now, zkEthscriptions is more like a stateless indexer. You can store state somewhere (maybe back to onchain) by using our zkAutomatoin to automatically access, compute and submit data.

Bonus: Other Latest zkGraphs in HyperOracle Ecosystem

In addition to zkEthscriptions, we have also seen the HyperOracle ecosystem, especially zkGraphs, flourish.

Here’s three latest zkGraphs by ecosystem developers we see:

These three use cases explore the application of HyperOracle zkOracle and zkGraph to compliance, sovereignty, and DID.

Come Build with Us!

We've put together use cases in awesome-hyper-oracle. You can use zkGraphs and zkOracles for:

  • More complex computational power that can be verified onchain

  • Access to more historical data or multiple data sources

  • The ability to perform automation calculations for rich interactions

Share your ideas and tag us on Twitter or Discord. Come build with us!

We recently launched the Hyper Scholar Program to help you get started in the HyperOracle ecosystem.


About HyperOracle

HyperOracle is a programmable zkOracle protocol that powers smart contracts with arbitrary compute and richer data sources. HyperOracle offers full security and decentralization for trustless automation and onchain AI/ML so builders can easily create next-gen dApps.

hyperoracle.io | x.com/hyperoracle | github.com/hyperoracle