SkillAgentSearch skills...

Kakarot

Kakarot is a zkEVM written in Cairo, leveraging the STARK proof system.

Install / Use

/learn @kkrt-labs/Kakarot
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<p align="center"> <img src="docs/img/kakarot_github_banner.png" width="700"> </p> <div align="center"> <h3 align="center"> Kakarot, the zkEVM written in Cairo. </h3> </div>

GitHub Workflow Status GitHub GitHub contributors GitHub top language Telegram Contributions welcome GitHub Repo stars Twitter Follow Discord

Update

This repository - an EVM emulator on Starknet - is frozen at latest audited and tested commit: 5caaf28e6188ea8b3726a2db5d4940ecb5afd898. The team is working on keth, an Ethereum Prover. Contact us on Twitter or Discord if you would like to use the EVM emulator on Starknet in production.

Introduction

This repository contains the set of Cairo (Cairo compiler version Zero) programs that implement the core EVM logic of Kakarot zkEVM.

Kakarot is an EVM implementation in Cairo. Cairo being a high-level zero-knowledge domain specific language (zkDSL), Kakarot is provable by design. This allows for proving the execution of EVM transactions, and makes Kakarot a de facto so-called zkEVM.

We strongly believe the CairoVM will provide the best zero-knowledge toolbox in the coming years and that the Ethereum network effect will remain prevalent. We present to developers an abstraction layer they're familiar with: the EVM. Build and deploy as if you were working on Ethereum, be forward compatible with the future of zero-knowledge.

Kakarot presentations and talks around the world

Getting startedBuildTestReport a bug

Supported opcodes

We support 100% of EVM opcodes and 9 out of 10 precompiles.

Documentation

Architecture

Here is a high-level architecture diagram of the entire Kakarot zkEVM system.

<p align="center"> <img src="./docs/img/architecture.png" width="70%" alt="Kakarot high-level architecture"> </p>

The set of Cairo programs in this repository are represented below:

<p align="center"> <img src="./docs/img/core_evm_diagram.png" width="60%" alt="Kakarot Core EVM diagram"> </p>
  • ✅ Kakarot Core EVM is a set of Cairo programs

  • ✅ Kakarot can be packaged as a smart contract and deployed on any chain that runs the CairoVM (StarknetOS chains, Starknet Appchains, Starknet clients).

  • ✅ Kakarot is an EVM implementation.

  • ⚠️ Kakarot Core EVM (the Cairo programs in this repository) is not a blockchain by itself. Combined with an underlying CairoVM chain, an RPC layer, it forms an EVM runtime embedded inside a Starknet appchain.

  • ❌ Kakarot is not a compiler.

Getting started

To contribute and setup your development environment, please check out the contribution guide.

Build

The project uses uv to manage python dependencies and run commands. To install uv:

curl -LsSf https://astral.sh/uv/install.sh | sh

To setup the project and install all dependencies:

make setup

To build the CairoZero files:

make build

To build the test Solidity smart contracts:

# install foundry if you don't have it already
# curl -L https://foundry.paradigm.xyz | bash
# foundryup
make build-sol

Code style

The project uses trunk.io to run a comprehensive list of linters.

To install Trunk, run:

curl https://get.trunk.io -fsSL | bash

You can also add Trunk to VSCode with this extension.

Then, don't forget to select Trunk as your default formatter in VSCode (command palette > Format Document With > Trunk).

Once Trunk is installed, you can install a pre-push hook to run the linters before each push:

trunk git-hooks sync

Test

Kakarot tests

Kakarot tests uses pytest as test runner. Make sure to read the doc and get familiar with the tool to benefit from all of its features.

# Runs a local CairoVM client (or StarknetOS chain)
make run-nodes

# Run all tests. This requires a Katana instance and an Anvil instance running in the background: `make run-nodes`
make test

# Run only unit tests
make test-unit

# Run only e2e tests
make test-end-to-end

# Run a specific test file
pytest <PATH_TO_FILE>

# Run a specific test mark (markers in pyproject.toml)
pytest -m <MARK>

Test architecture is the following:

  • tests/src contains cairo tests for each cairo function in the kakarot codebase running either in plain cairo or with the starknet test runner;
  • tests/end_to_end contains end-to-end tests running on an underlying Starknet-like network (using the Starknet RPC), currently Katana. These end-to-end tests contain both raw bytecode execution tests and test on real solidity contracts.

The difference between the starknet test runner (when using contracts) and the plain cairo one is that the former emulate a whole starknet network and is as such much slower (~10x).

Consequently, when writing tests, don't use contracts unless it's really required. Actually, for tests requiring a Starknet devnet, prefer end-to-end relying only on a RPC endpoint and currently running on Katana.

For an example of the cairo test runner, see for example the RLP library tests. Especially, the cairo runner uses hints to communicate values and return outputs:

  • kwargs of cairo_run are available in the program_input variable
  • values written in the output_ptr segment are returned, e.g. segments.write_arg(output_ptr, [ids.x]) will return the list [x].

Both cairo and starknet tests can be used with the --profile-cairo flag to generate a profiling file (see the --profile_output flag of the cairo-run CLI). The file can then be used with pprof, for example:

go tool pprof --png <path_to_file.pb.gz>

The project also contains a regular forge project (./solidity_contracts) to generate real artifacts to be tested against. This project also contains some forge tests (e.g. PlainOpcodes.t.sol) which purpose is to test easily the solidity functions meant to be tested with kakarot, i.e. quickly making sure that they return the expected output so that we know that we focus on kakarot testing and not .sol testing. They are not part of the CI. Simply use forge test to run them.

EF tests

To run the Ethereum Foundation test suite, you need to pull locally the Kakarot ef-tests runner. To simplify the devX, you can create symlinks in the ef-tests repo pointing to your local changes. For example:

ln -s /Users/clementwalter/Documents/kkrt-labs/kakarot/blockchain-tests-skip.yml blockchain-tests-skip.yml
mkdir build && cd build
ln -s /Users/clementwalter/Documents/kkrt-labs/kakarot/build/ v0
ln -s /Users/clementwalter/Documents/kkrt-labs/kakarot/build/fixtures/ common

With this setting, you can run a given EF test against your local Kakarot build by running (in the ef test directory):

cargo test <test_name> --features v0 -- --nocapture
# e.g. cargo test test_sha3_d7g0v0_Cancun --features v0 -- --nocapture

See this doc to learn how to debug a cairo trace when the CairoVM reverts.

Deploy

The following describes how to deploy the Kakarot as a Starknet smart contract on an underlying StarknetOS network.

It is not a description on how to deploy a solidity contract on the Kakarot EVM.

Note that the chosen chain_id when deploying is important:

  • To keep compatibility with metamask the max chain id is 4503599627370476 see https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
  • To be compatible with ledger the chain id needs to be inferior to 4 bytes see https://github.com/kkrt-labs/kakarot/issues/1530

The deploy script relies on some env variables defined in a .env file located at the root of the project and loaded in the constant file. To get started, just

cp .env.example .env

The default file is self sufficient for using Kakarot with KATANA. If targeting other networks, make sure to fill the corresponding variables.

Furthermore, if you want to run the check-resources locally to check the steps usage of your local changes in the EF tests against main and other branches, you need to fill

Related Skills

View on GitHub
GitHub Stars1.0k
CategoryDevelopment
Updated7d ago
Forks316

Languages

Cairo

Security Score

100/100

Audited on Mar 16, 2026

No findings