Chapter 3: The World’s 1st On-Chain AI Project

Modulus Labs
7 min readAug 19, 2022

--

Hello world!

Today is a really exciting one for us. To start, we can finally talk about what we’ve been hard at work on for the past couple weeks —

The Rockefeller Bot: The World’s First Fully On-Chain AI Trading Bot (www.rockybot.app)

And just in case that wasn’t enough news, we’re also taking this opportunity to announce the official launch of Modulus Labs (moduluslabs.xyz), our company building the technology we need for true on-chain artificial intelligence.

If you need a quick catch-up on what we’ve been thinking about, make sure to check out Chapter 1 and Chapter 2 of our blog. And hey, thanks for being here— we’re huge believers in working in an open, collaborative fashion, and that means nothing without you!

But alright alright, we’re gonna roll back the touchy-feelies for a bit and get to last notes before the ride today: make sure to keep your hands within the vehicle at all times, don’t intentionally frighten the web2 dinosaurs, and follow us on Twitter — lots of exciting news coming soon, and that’ll be the best place to stay in touch through all of it.

Alright, here we go!

Hello to AI, now validated on-chain :)

The Rockefeller Bot: The World’s First On-Chain AI Trading Bot

Money. It runs the world. Until now… because:

Rocky now runs money.

Jokes aside, the launch of the Rockefeller Bot is an important moment. To the best of our knowledge, this is the first fully on-chain deployment of an AI algorithm to mainnet, in the history of both Ethereum and blockchain (shout-out to @guiltygyoza for his inspirational MNIST classifier on StarkNet!!). This means that Rocky’s operations are, in the truest DeFi protocol sense, entirely autonomous and validated via the golden security standards of Ethereum. We’ve started him up with a good inheritance, but everything from here on out is, well, on him.

Results from an early test of the Rockefeller bot: rockybot.app

How Does Rocky Work?

Rocky lives on the StarkNet roll-up, having been trained on historic price/exchange rate data between WEth and USDC. Architecturally, Rocky is a simple three-layer feedforward neural net which predicts, given historical market price data, whether (and by how much, discretized into buckets) the price of WEth will increase or decrease. This means that, crucially, when Rocky makes a decision about what to trade, it generates a StarkNet proof immutably linked to the output which is posted and ultimately verified on Ethereum. Once Rocky has decided which trade to make and how much to trade, he sends the information to an L1 contract, which is a simple interface with a Uniswap router. The L1 Contract holds all the money, can accept more money, and only making trades when Rocky tells it to. The advantage of this system is that Rocky’s money is not under the control of some centralized authority, but rather that of a public algorithm. And in this case, one complicated enough to take into account live market conditions.

Will Rocky Make Money?

Rocky, for all his charm, is ultimately trained on noisy market data

No. The Rockefeller bot will not make you money. Instead, Rocky is meant to serve as a technical demonstration — specifically, a demonstration that with a bit of work, we can in fact create a trustless, autonomous agent on Ethereum. That’s right — like a DeFi protocol, there’s really not much we at Modulus Labs can do to it now. It’ll just keep on executing via its source code which lives entirely on-chain.

You can, however, donate any amount to #KeepRockyAlive — because Rocky, in his finite wisdom, will trade and swap until he absolutely exhausts his resources and can’t even afford gas fees (sad 😢). While Rocky continues to execute according to his whims, we’ll send you an NFT to commemorate the moment, as a thank you for keeping him going.

#KeepRockyAlive NFT with original composition by DALLE

Goals & Limitations

Our goals for the Rockefeller bot are threefold:

  1. Show that we can put verifiable AI inference on-chain (despite the many restrictions today)
  2. Give interested people a way of interacting with Rocky
  3. Begin to build a community around putting AI on-chain

While Rocky is a relatively simple technical PoC, we see a future of increasingly complex autonomous agents alongside ever-larger sums of money. Building with this future in mind, we’ve chosen to verify Rocky’s compute via zero-knowledge-proofs/rollups; as we’ve been learning in web3 recently, unless you build on a foundation of rock-solid cryptography, you will eventually get pwned.

We’d also like to take a moment to acknowledge some of the limitations of this PoC (a hint for our roadmap? One ought to wonder what it will take to make sophisticated models available to smart contracts at the touch of a keystroke…). Here’s a smattering of what we encountered developing Rocky:

  • Floating point numbers must be approximated by field elements, as must their operations
  • To make neural net functions flexible (similarly to PyTorch allowing developers to state flexible input/output sizes for their layers), we ended up passing all of our model parameters in, per-inference, through network requests
  • The rate-limiting factor ended up being L2-L1 communication and proof verification, as the L1 contract could not make a trade until Rocky’s (running on StarkNet’s L2) output was verified on L1

If you’d like to see Rocky for yourself (and re-train, fiddle with, or deploy for ultimate profit generation at your own risk!!), here is his GitHub monorepo, here is a permalink to his L2 contract with the neural net code inside, and here is his L1 contract on Etherscan!

Rocky bot’s vision-board involved a lot of extravagance

Our Company: Modulus Labs

Alright, alright. We know the cat’s already out of the bag, but hey, it’s still important to put it out there for sentimental reasons:

We are officially starting Modulus Labs, the on-chain AI company (though we’re known as M-Labs to the cool kids, and ML to the frozen, frigid kids).

Our hope is to make Modulus — along with our community (that’s you!) — *the* place to be for those interested in the intersection of AI and blockchain. And we want that to be true for developers, model operators, and regular folks alike. Our only requirement is excitement about trustless autonomy! And hey, a good place for all that discussion is definitely our Discord.

And of course, we need to take a moment to thank the talented folks at Floodgate Ventures (shout-out to Ann and Tyler!). Their support of us, from day one, has been instrumental to our path so far. They’ve also given us the gas we need to continue to bring you updates in the weeks and months to come. We’re so very lucky to get to work on such an exciting project, and our minds are already buzzing with possibilities of what y’all will do with verifiable AI.

Our Vision for What’s Next

We believe in a strong case for the future of web3. But you don’t have to.

In fact, so long as you believe that crypto — whether DeFi alone, or the growing ecosystem of dApps as well — will grow to occupy an ever larger share of the overall internet economy, on-chain intelligence seems all but inevitable. After all, the legacy of smart contract logic is one of increasing complexity and sophistication (see entire games being built on-chain, or oracles based around verifiable data pipelines). Our instinct is that much as it has done for web2, artificial intelligence will radically transform smart contract logic. It will make web3 more personal, capable, and of course, do so while retaining the new standard of security established by Ethereum.

What that future will look like, precisely, we don’t know yet. But our bet is that verifiable AI will be an important and necessary part of that future.

That’s why our invitation to you is a simple one:

Come build that world with us

Whether you are a developer interested in incorporating on-chain intelligence, an academic keen to propose a new technique for prover efficiency, or a fan who wants to stay on top of every development in the space, join our tribe and help define the next era of the internet, together.

The future of verifiable AI awaits!

Getting in Touch

All of us on the dev team will do our best to stay on top of our dms. The fastest way to get our attention? Probably Discord, but here are all of the relevant places to find us just in case:

Alright! That’s all for now folks. Back to building. Stay in touch: lots more news to come 😉

--

--