StarkWare x StarkNet x Layer 3+ : The Ultra Scalable ecosystem

Exo Monk
13 min readApr 21, 2022

--

The emergence of new blockchains & the technical improvements they bring are more and more felt. We see the interest of Layer 2 growing and their development accelerating because of the need to increase the scalability of solutions.

In the continuation of this reflection, I propose a complete analysis of the StarkNet environment, which brings many innovations in the possibilities that a Layer2 can offer.

The article will cover to begin with all the essential notions to understand the topics discussed (Zero Knowledge, ZkRollup, …). I think that anyone interested in cryptocurrencies and blockchain technology must assimilate this knowledge.

In a second time, I will present the parent company StarkWare which develops StarkNet/StarkEx through the solutions that are built and will be built. This article will be technical but at the same time affordable. This will be done through an introduction to the Smart Contract language of StarkNet: Cairo and its specificities compared to Solidity in particular, and some atypical and innovative subtleties.

To finish with, I shall share with you a small list of projects under construction & to be followed on the environment which will certainly play an important role in the explosion of the ecosystem.

Glossary :

Zero Knowledge, ZKSTARK & Rollup

Let’s start with the basics of vocabulary, you will see that the terms may seem barbaric, but in the end they are as soft as cotton.

Zero Knowledge Proof

While blockchain has brought us great benefits such as transparency, immutability & decentralization, the notion of privacy is rarely discussed. This is where Zero Knowledge Proof (ZKP) comes in: a juicy mix of composability, privacy & immutability.

ZKP is an encryption scheme by which one party (the PROVIDER, which we will call PR) can prove the veracity of specific information to another party (the VERIFIER, which we will call VER) without disclosing any additional information.

In a concrete example, VER wants to collect a reward from a vault. In ZK, this gives:

  • PR confidentially produces a key (K)
  • VER verifies that the key (K) allows to obtain the reward
  • The ZKP is verified, CQFD

In a same way, ZKP can also resolve:

  • PR produces a key (K) and retrieves the reward from the vault confidentially
  • VER verifies that the reward corresponds to a reward that is only available in this same vault
  • The ZKP is verified, CQFD

In summary, the VER verifier will not know any information other than the boolean statement. The details of the other parties’ information and personal data remain anonymous.

As you can see, ZKP allows for privacy. But what is interesting with this method is that it is extremely simple, secure & allows an incredible scalability, it is chosen by many blockchain applications for these virtues.

Rollup & Zk-Rollup

An Ethereum Rollup is an off-chain aggregation of transactions within an ETH smart contract, which reduces fees and congestion by increasing throughput from its current 15 tps to over 1000 tps. It’s like having blockchains in the shadows that aggregate ETH blocks. (→ https://twitter.com/0xExoMonk/status/1486729691243298819)

ZK-Rollups are one of the options under development for building Layer 2 that increase scalability by processing mass transfers in a single transaction. Where Plasma creates one transaction per transfer, ZK-Rollups aggregate hundreds of transfers into a single transaction. The Smart Contract will deconstruct and verify all transfers held in a single transaction: another proof of scalability.

A ZKP approach is used to publicly present and record the validity of the block on the Ethereum blockchain. ZK reduces the computational and storage resources to validate the block by reducing the amount of data held in a transaction; no knowledge of the dataset is required.

ZKSNARK — ZKSTARK

I will introduce the last keys of this article: ZKSNARK & ZKSTARK, which are in fact two different types of Zero Knowledge proofs. A little background.

The ZK-Rollup scheme consists of two types of users: Relayers & Transactors.

  1. Transactors create their transfer and broadcast the transfer over the network. The Smart Contract stores the data in two Merkle Trees (https://fr.wikipedia.org/wiki/Arbre_de_Merkle):
  • The addresses in one Merkle Tree
  • The transfers of the amounts in another one.

2. The Relayers collect a large amount of transfers to create an aggregate. It is the job of the relays to generate the SNARK proof: ZKSNARK

The SNARK proof is a hash that represents the delta of the blockchain state. The SNARK proof compares a snapshot of the blockchain before the transfers to another snapshot of the blockchain after the transfers and reports only changes in a provable hash to the main network.(https://blog.ethereum.org/2016/12/05/zksnarks-in-a-nutshell/)

Prior to ZK-STARK, ZK-SNARK was used to create ZK proof systems, but required a trusted party or parties to initially configure the ZK proof system, which introduced the vulnerability of those trusted parties compromising the confidentiality of the entire system. ZK-STARK improves on this technology by removing the need for a trusted configuration.

As you can see, this new proof solves one of the biggest flaws of the old SNARK proof. This proof has been proposed by the StarkWare team in its Starknet environment that I will present later.

STARKs improve two of the problems of permissionless blockchains: scalability and privacy.

STARKs improve scalability by allowing developers to move computation and storage off-chain. Off-chain services will be able to generate STARK proofs attesting to the integrity of off-chain computations. These proofs are then delivered back to the chain for any interested party to validate the computation. Moving the bulk of the off-chain computation work using STARK allows the existing blockchain infrastructure to scale exponentially while confidently maintaining the integrity of the computations: it’s a game-changer asset.

Good! You now have all the keys in hand to enter the StarkWare: StarkNet ecosystem.

Starware x StarkNet

StarkNet is a decentralized, permissionless ZK-Rollup (ZKP-based) and uses ZKSTARK technology to scale exponentially without compromising privacy.

StarkNet Alpha was released on public testnet in June and on Mainnet in November of 2021. At the time of the Mainnet deployment, StarkNet was already providing general purpose computing in an Ethereum-like state.

Throughout development, the StarkWare team chose an approach that focused on releasing the most important features first, essentially sharing the evolution process with the community.

StarkNet is far from complete, but even now, developers can already create meaningful and complex applications. Today, there are hundreds of developers who rely on StarkNet, lot of dApps, and some external teams developing tools and infrastructure for the StarkNet ecosystem (which we will see in the last section).

A series of updates has provided many important features. Several caught my eye:

  • L1 <-> L2 messaging,
  • On-chain data and composability support
  • Events support
  • Basic pricing mechanism, Contract upgrade
  • Wallet abstraction (which are now Smart Contracts)
  • Testing framework, development tools, rapid confirmation

Since the beginning of the year, the ecosystem has reached its usability threshold: it is possible to build complete and amazing dApps. The team will now focus on the performance of the system: in its current state, it is capable of supporting a limited transaction flow. The goal is to achieve a TPS at least an order of magnitude higher than Ethereum’s by the beginning of the second half of 2022, at a cost at least two orders of magnitude lower than Ethereum’s.

StarkNet must be a fully decentralized permissionless network with mechanisms for leadership election and governance. Achieving this goal will become the primary objective once throughput skyrockets and costs drop.

StarkEx is the scaling engine for some of the most successful dApps using L2: dYdX(perpetual contracts), DeversiFi (trading and cash payments), and for Immutable X (IMX) and Sorare (NFT typing and trading) now.

Let’s talk about Fractal Scaling : Layer 3 & more

The exorbitant cost of transactions on Ethereum asymptomatically pushes L2s to meet those same costs. StarkWare’s paradigm is that, end users will conduct the majority of their business on L2s due to the dramatically reduced transaction costs, growing support for DeFi tools, and the increased liquidity provided by them. L2s increase scalability with reduced gas cost per transaction and improved transaction rates. At the same time, L2s retain the benefits of decentralization, general purpose logic and composability. However, some applications require specific customization that can be better served by a separate new layer: Let’s talk about Layer 3.

An L3 relates to an L2 as an L2 relates to an L1. L3s can be realized using validity proofs as long as the linked L2 is capable of supporting a Smart Contract Verifier (see Part 1). When L2s also use validity proofs submitted to an L1, as StarkNet does, it becomes a demented recursive structure where the compression benefit of L2 proofs is multiplied by the compression benefit of L3 proofs.

In other words, if each layer achieves, for example, a cost reduction of ratio 1000, the L3s in question can achieve a reduction of ratio 1M compared to the L1, while maintaining the same security. One could then imagine a transaction fee that would cost a fraction of the usual gas fee.

StarkWare explains the advantages of having a Layer 3:

  • Hyper-scalability: taking advantage of the multiplicative effect of the recursive proof.
  • Better control by the application designer of the technology stack:

More deterministic performance and cost
Customized data availability models (e.g., Validium-based or application-specific compression of chained data),

Faster functionality and technology speed (e.g., introducing new features that are not yet ready for general availability).

  • Confidentiality: ZKP applied to privacy-preserving transactions on a public L2.
  • Interoperability: independent L3s will interact via the L2, not the L1. L2 should obviously be cheaper than its L1.
  • L3 as a “canary” network à la Kusama for Polkadot for the L2: new innovations can be tested on the L3 before being made available to the general public.

In the same way, we are kindly offered an example proposed by StarkWare to expose this theory of a Layer 3:

  • A StarkNet with Validium data availability, for example, for general use by extremely price sensitive applications.
  • Application-specific StarkNet systems customized for better application performance, for example, using designated storage structures or data availability compression.
  • StarkEx systems (such as those serving dYdX, Sorare, Immutable, and DeversiFi) with Validium or Rollup data availability immediately bring combat-proven scalability benefits to StarkNet.
  • Privacy StarkNet instances (in this example also as L4) to enable privacy-preserving transactions without including them in public StarkNets.

Smart Contract on Starknet : Cairo

StarkNet is built on the Cairo programming language, the first production-level full von-Neumann Turing checker on Ethereum. It is in fact the language for Smart Contracts on the ecosystem. Cairo allows developers to use the power of ZKSTARK to create fully scalable applications. Let’s take a closer look.

Cairo : Smart Contracts

Cairo is a language for writing provable programs: the execution of a Cairo program produces a trace that can then be sent to a prover, which generates a STARK proof of the validity of the instruction or calculation represented by the Cairo program. The proof can then be checked with a verifier.

Today, most dApps are built around Smart Contracts Solidity implementing some kind of logic & interface, and a backend. These dApps, when successful, inevitably face the problem of scalability.

Increasingly, we see dApps solving their scalability problems by turning to evidence-based L2 scalable solutions (like DeversiFi with StarkEx). An off-chain component supports some of the more complex parts of the business logic and communicates with on-chain smart contracts, without giving up security, as all changes to the system state are certified by evidence (ZKP). Scalability improves because verifying an on-chain proof is exponentially cheaper than executing the business logic entirely on-chain.

With Cairo, the barriers to using proofs to achieve scalability are much lower: you write logic in Cairo, then the code has to be proven off-chain, and once that proof is validated on-chain, you end up with a dApp that can use the result with confidence — just as if it had run it on-chain.

Three points are expensive on Ethereum: computation, transmission and storage.

Cairo solves all three. To understand how it does this, we need to introduce a new concept — The Shared Prover (or SHARP).

The SHARP is the link between your Cairo code and your Smart Contract Solidity. It has three main components: a prover (off-chain), a smart contract verifier (on-chain) and a fact logger contract (on-chain).

The prover takes the execution trace of your program, proves that it is valid and sends this proof to the verifier. After verifying the proof, the on-chain verifier takes one more important step: it writes a fact attesting to the validity of the proof in the fact register. This fact is like a seal of approval without trust, certifying that the Cairo program was calculated correctly. Now all that is left for the dApp’s smart contract is to verify that this fact exists, in order to rely on the computation that was performed off-chain.

To go further into this development environment, I leave you with this notion :

https://seen-joke-82c.notion.site/StarkWare-Development-965f54711eb84dc79f3b61f22df9e383

Must Follow Projects on StarkNet

But now that you have understood everything about ZKP, StarkNet & Cairo, what to do?

StarkNet Wallet : ArgentX

The first step will be to configure your wallet. We will use ArgentX:

Unlike Ethereum L1 where private keys and accounts are generally the same thing (think EOA wallets), StarkNet supports account abstraction, meaning that each account is actually a Smart Contract that must be deployed before it can interact with the network. This is both a fantastic opportunity and an added complexity for a normal user.

The ArgentX wallet is used here to abstract away the complexity: it creates and secures private keys, deploys key-controlled account contracts, connects to decentralized applications and sends transactions to the StarkNet network.

Using a Smart Contract as a wallet is, in my opinion, a big step forward in security. ArgentX offers the same way to create Vaults as a wallet (thus automated multi-sig). All transactions with untrusted addresses are automatically blocked, unless you use guardians. This security covers all assets & transactions with trusted addresses are transparent

Currently, the available applications are mainly on the testnet of StarkNet, & to use them, you will have to get test tokens: https://faucet.goerli.starknet.io/

StarkNet Bridge

The 2nd most important thing to know: how to transfer funds from an L1 (Ethereum) to the L2 Starknet. The answer is in the StarGate bridge:

We will remain cautious though as this is again an Alpha, not yet audited.

StarkNet DEX — AMM

We shall start with what we are all looking for when entering a new ecosystem : DEX, Trading & AMMs.

As of today, several dApps stand out from the crowd:

https://info.zigzag.exchange/

A decentralized exchange built around ZKP, with an OrderBook.

  • ZKX: Perpetual Trading

https://twitter.com/zkxprotocol

https://medium.com/starkswap/the-starkswap-vision-6c73f8e66aab

A decentralized exchange with an Automated Market Maker

StarkNet Lending

https://linktr.ee/zkLend

zkLend is a money market protocol based on StarkNet. ZkLend offers a dual authorization suite of compliance-oriented solutions for institutional clients (“Apollo”) and an authorization-free service for DeFi retails users (“Artemis”).

StarkNet Launchpad

As usual, in my opinion one of the focal points of a new ecosystem: the launchpad. The goal of the ZkPad gas pedal is to provide founders with strategic and operational support, including co-marketing on Twitter/Discord, partnership and ecosystem intros, access to a database of selected talent, including Cairo developers, UX/UI designers and marketers. The platform is specifically designed to open up investment opportunities, previously reserved for investment funds, to individuals.

StarkNet DeFi

https://twitter.com/magnetyfi

Magnety is an asset management protocol allowing anyone, such as investment groups, DAOs or individuals to create and manage a hedge fund via the Starknet & L1 DeFi ecosystem. The protocol allows you to create a highly customizable vault based on an investment strategy that you can choose. In my opinion a DeFi product to follow, highly secure thanks to ZKP.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

You will find a non-exhaustive list of projects under construction on StarkNet: https://starkware.notion.site/Projects-Building-on-StarkNet-a33dee55778a4515a9be9bdae02ee682

Follow More content :

https://twitter.com/0xExoMonk

--

--

Exo Monk

Blockchain - ML - Data Tech Lead | Writing about dev stuff and Blockchain | https://twitter.com/0xExoMonk