msfew

Posted on Feb 09, 2024Read on Mirror.xyz

Framing the Future of DApps with zkOracles

TL;DR

  • Farcaster is an open social network, and Frames, a new feature by Farcaster, enables open innovation of applications on Farcaster.

  • zkDApps (zkOracle + DApp) can be integrated with Farcaster Frames to build novel applications.

  • #1: Build applications with Frames as the frontend and zkDApps (smart contract + zkOracle) as the backend, for better UX and visibility.

  • #2: Build zkDApps with zkOracles as trustless backend.

  • #3: Build AI oracles powered Frames, basically GPTs but with Frames.

0. Farcaster & Frames

a) Introduction

Farcaster is not only a Twitter replacement, but also an open social network. It has client interfaces such as Warpcast. It is literally Crypto Twitter, because every account is based on crypto accounts with features like an onchain password reset enabling easy onboarding and improving crypto UX.

https://twitter.com/AlanaDLevin/status/1755243228658368633

Farcaster is sufficiently decentralized with its core data stored on blockchain. In Farcaster, every short message posted is called a “cast”, similar to Twitter’s “tweet”.

Frame, a new feature on Farcaster, allows interactive content to be embedded inside a cast itself. Any user can interact with a Frame like the cast is its own mini application. Besides the traditional preview of webpage as an image, Frames has buttons for users to interact with dynamic content.

You might compare Farcaster’s Frames to something like iframe. However, Frames are cool because they are:

  • Interactive (Users can interact with the frame, and get updated content. For example, play chess or even DOOM by interacting with a user’s cast)

  • Instant (Users don’t need to leave the platform or even the cast to interact with the Frame. For example, you can browse and select items you want to buy from a user’s online store, although the final checkout step may be outside the platform.)

  • Open Innovation (Frames are basically Farcaster’s Uniswap v4 Hooks. Developers can freely build on the platform.)

  • Composable (A Frame can contain several Frames together.)

Here’s a developer’s explanation and guide:

b) Awesome Frames

We've seen a lot of interesting Frames in just a few days.

A lot of games use a Frame as the frontend: Onframe-chess (Chess game as a Farcaster Frame), Magic Trick (Card magic trick game as a Farcaster Frame), Doom (Classic Doom in Farcaster Frame. And a writeup), Yoink!, Rock, Paper, Scissors, Tarot Cards

Other Cool Frames: cast a Mirror blog into Frames, frame-eas, mint a song, mint generative art, create a faucet…

Also bounties for Frames: Bountycaster, Livepeer’s onchain video frame

And ongoing draft specs: simplify external links, “mint” action

1. Building a zkDApp with Farcaster Frames

HyperOracle is a programmable zkOracle protocol.

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 computations in a trustless and secure way.

zkDApp = DApp + zkOracle.

Here are some use cases we can think of where Frames can be combined with the zkDApp infrastructure.

For more information on what we are building check out our litepaper.

a) Frames as a Frontend for a zkDApp

The first obvious use case is to use Frames as a frontend for a zkDApp. This would give the zkDApp exposure to social media audiences on Farcaster.

You can build any zkDApp, and then build a Frame-based frontend instead of a traditional web front-end. The advantage of this is that you can leverage Farcaster's reach and ease-of-use to give the zkDApp more visibility. Eventually, zkDApps built in this way will get recommended through social media algorithms to the most aligned users.

One thing to keep in mind is that a Frame-based frontend may have some limitations over a normal web frontend, such as only being able to render each page as an image. Also, Frames have a special key model for seceurity by separating the social account key from the account fund key.

b) Frames with a zkOracle as a Trustless Backend

In addition, if you want to build a Frame-based Crypto-related application, you can use a zkOracle to implement a "backend". This may be similar to an SGX-based Frame.

Although Farcaster can guarantee that the input to the Frame is validated by the user by providing a signed message, when the input to the Frame goes to the backend of the Frame, the backend of the Frame may return incorrect data, which may be intentionally done to confuse the user.

Don’t trust, verify. By verifying the ZK Proof in the Frame front-end, we can ensure that the entire Frame application is verifiable and correct. Frames with zkOracle as a trustless backend is like adding an extra check/guarantee for more important (financial-related) Frames. All it does is giving Frames a way to let their users check the validity of the results by themselves in their frontend.

Therefore, we can purely access a zkOracle as the backend to return not only the data, but also a ZK Proof generated by a zkOracle.

To learn more about integrating zkOracles in your backend or JS frontend, check out this amazing example of gameOfLife by Mingzhe. It implements a Game of Life in a zkOracle and runs a zkOracle as a trustless backend with the zkgraph-api library integration.

c) Frames with Onchain ML

We also have special Frame-related use cases. You can build an AI-based Frame application based on our onchain AI Oracle (OAO).

We will soon be releasing our onchain AI Oracle. We're making it easy for developers to trigger or leverage AI functionality onchain. In the development of Frame apps, developers only need to integrate with onchain contracts to utilize the AI functionality.

Just like GPTs, but for Frames!

What applications can you build, that work well inside Frames and Farcaster’s social protocol?

🦾 Build with Us!

We've put together some exciting and interesting use cases in awesome-hyper-oracle. You can use them as inspiration for building your next Frame project.

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