A Keyko Case Study — Building an L2 chain with Optimism for Mode Network’s launch

At Keyko, we know what it takes to build blockchains, as we’ve been involved in a few L1 projects (Filecoin, Celo,…). Getting a protocol layer right really requires a different approach than building a dApp. So when Mode Network reached out to build their brand new L2 chain, we jumped at the opportunity.

These days, launching a new blockchain network is as simple as deploying a smart contract. Or is it?

 

With the Ethereum L1 chain becoming increasingly solid, we’ve seen a proliferation of L2 and even L3 chains. The idea is that chains can be finetuned and configured to become use-case specific, while relying on shared security and cross-chain interoperability.

 

At Keyko, we know what it takes to build blockchains, as we’ve been involved in a few L1 projects (Filecoin, Celo,…). Getting a protocol layer right really requires a different approach than building a dApp.

 

So when Mode Network reached out to build their brand new L2 chain, we jumped at the opportunity.

 

Superchain: Standing on the Shoulders of OP Giants

 

Mode is an early adopter of Optimism’s vision of the Superchain. While originally devised as an L2 chain on top of Ethereum, the Optimism team have felt the need to look at the fundamental issue of decentralized scalability. The Superchain concept they’ve devised is about creating a network of chains that share bridging, decentralized governance, upgrades, a communication layer and more.

 

To make that feasible and to create these OP Chains, they have built the OP Stack.

 

Source: https://docs.optimism.io/

 

Then, what is Mode?

 

Just like Coinbase’s Base network, Mode is one of those OP Chains, mainly focused on DeFi applications. Its vision is to power a new on-chain economy that rewards contributions to network growth and network usage. So their first target audience is dApp-developers.

 

When they reached out to us, in the early stages of their project, they were convinced that having their L2 network powered by Optimism, was the way to go. So we helped them validate their tech decisions and then implemented this new stack to launch their brand new blockchain at speed.

 

Along the way, we learnt 5 things, which we’d like to share.

👇

 

1. The Infrastructure: deploy in minutes, not months

 

We’re a battle-tested team of developers here at Keyko. So when we read one-liners like ‘Deploy in minutes, not months’, we tend to shrug.

 

However…

 

We must say that it was a pleasure to work with the OP Stack. Deploying the roll-up contracts on the Ethereum L1 is a breeze and the way they connect to the L2 contract is, what we would call, elegant.

 

A lot of that elegance has to do with the partnership that Mode set up with Conduit, who specialize in deploying networks in production-ready environments for Optimism (and for Arbitrum). Not only was their support very good, their approach of running Infrastructure As Code, makes setting up an Optimism L2 pretty easy.

 

Need a block explorer? Comes out of the box.

Need oracles for listening to messages? Comes out of the box.

Need a bespoke Sequencer to set your own fee conditions? Comes out of the box.

Need a bridge? OK, a few months ago, we still had to create a bridge ourselves, but now, that comes out of the box as well.

 

What Keyko did:

 

  • Analysis of architecture
  • Set up support partnership
  • Deploy OP Stack

 

Photo by Dan Cristian Pădureț on Unsplash

 

2. Building dApps

 

As said, Mode wants to stimulate dApp development. And we all know what developers want: easy tooling.

 

We stress-tested the stack and built some applications on the Mode testnet and we can confirm: it’s the same as building for any EVM chain.

 

Solidity: check

ERC standards: check.

Dev tooling: not necessary.

 

And if you want to copy/paste your DeFi dApp across from another network into Mode, that can be done too.

 

What Keyko did:

 

  • Build Bridge dApp for testnet
  • Support dApp developers

 

3. Bespoke Rewards

 

Source: https://docs.mode.network/introduction/sequencer-fee-sharing

 

One of the interesting USPs of Mode is that they want to reward developers directly. The idea is that this will stimulate app growth and avoid developers having to think about their own business models, fee structures or token creation. They can focus on building good apps and attract users.

 

The main Optimism chain works with a Sequencer vault to manage the payout of the transaction fees. But every Superchain built on the OP Stack comes with the option to configure your own Sequencer and reward conditions to fit your own economic model.

 

So what we did for Mode was build SFS, Sequencer Fee Sharing. This is a reward system that powers automated rewards. If a developer creates an app and registers it with the sequencer contract, the SFS will track all usage and transactions. Fees will accrue and after a certain period (currently bi-weekly), the fees will be split and 25% of the transactions will be rewarded to the app developer.

 

Again: elegant.

 

What Keyko did:

 

  • Build Sequencer Fee sharing contracts
  • Build back-end payout management tool

 

4. Data Availability

 

At some point in the process, the Mode management decided they wanted an Airdrop campaign to kickstart user growth. The formula for counting the token allowance was not a simple one. But that gave us the chance to dig into the concept of data availability. How could we get all the on-chain data to run our allocation algorithm off chain?

 

Again, because the OP stack uses available blockchain standards, we successfully designed a solution with a set of available tools. We used the Goldsky Indexer to get an idea of transactions, traces and logs. Plus, we used a subgraph from The Graph to monitor the FeeSharing contract.

 

By connecting all these components, we managed to create a data pipeline from the Mode network into our standard cloud database, in a matter of weeks.

 

What Keyko did:

 

  • Integrate Goldsky & The Graph
  • Build bespoke airdrop eligibility formula
  • Build data pipeline

 

5. DevOps rules

 

The benefit from using OP Stack is that you can create momentum pretty quickly. Speed is of the essence in Web3.

 

The downside is that you have to make architecture decisions pretty quickly. You are connecting API systems and front-end code, like, every single day. And having DevOps in place up front helps tremendously with minimizing risk.

 

Launching an L2 is possible out of the box using Conduit, but this is not sufficient. To go from a solid technical foundation to a successful network, you need to keep that holistic view and make sure all the pieces of that fast-moving puzzle stay connected.

 

Pro tip

 

We’d recommend anyone planning to do a similar exercise to enlist the skills of one or more DevOps, as the OP Stack is generic enough. This will help the founders and product team to manage the exponential complexity that comes with fast moving projects. From maintaining a plethora of API connections to running off-chain code and liaising with devs to deploy new features: launching Mode has shown us (again) the value of DevOps.

 

Follow us on Medium for more articles like this.