1. Research & development
  2. > Blog >
  3. EVM Rollups Are Coming to Tezos – Now on Testnet

EVM Rollups Are Coming to Tezos – Now on Testnet

announcements
18 July 2023
Nomadic Labs
share:

TL;DR: An EVM-compatible Smart Rollup is available on Ghostnet, Tezos’ permanent testnet. This blog post shows you how to get started with it.

Connect your Metamask wallet, deploy Solidity contracts with Remix, build dApps using Ethereum JSON-RPCs, and still benefit from the latest Tezos innovations!

We are happy to present EVM-compatibility on Tezos via an open source EVM Smart Rollup developed by Trilitech, Marigold, Functori and Nomadic Labs. As the next step towards Mainnet-readiness, an instance of this rollup has been deployed on the Ghostnet test network at block level 3289331.

This deployment is a community rollup, meaning it is an EVM-compatible execution environment where all interested community members and project developers can explore and experiment with EVM-development on Tezos.

With that goal in mind, this blog post provides instructions on how to interact with the deployed rollup using the Octez software suite.

What’s an EVM-compatible Smart Rollup?

The Ethereum Virtual Machine (EVM) is the execution environment in which all Ethereum accounts and smart contracts live. An EVM-compatible Smart Rollup is a rollup whose kernel implements an EVM-compatible execution environment. This enables Ethereum smart contracts to be frictionlessly deployed and executed on Tezos.

Because Smart Rollups allow developers to write applications written in any programming language that compiles to WASM, we were able to develop an open source kernel using an established implementation of the EVM in Rust, SputnikVM. This kernel creates a separate blockchain running in Tezos’ Layer 2, producing its own blocks and processing its own transactions.

Currently, there is one EVM block per Tezos block, but Smart Rollups are upgradable, and nothing prevents us from having different block times from Layer 1 in the future. We retrieve the list of transactions to include in EVM-rollup blocks by reading the Smart Rollups’ shared inbox. Thus, we use the Tezos network as our consensus layer, as it provides a sequence of transactions to include in Layer 2 blocks.

The EVM kernel is executed by an Octez Smart Rollup node, which is kernel agnostic and not equipped to communicate with Ethereum wallets or block explorers out of the box. For this, we provide another layer on top of the Octez rollup node in the form of an EVM node.

This facade node is provided as a new Octez binary. It currently partially supports Ethereum’s JSON-RPC API specification, but we aim to provide full support in the future, so as to achieve full compatibility with the Ethereum tooling ecosystem.

Getting started with the EVM rollup

For reasons well-explained here, we have decided to use Ctez as the native token for this deployment of the EVM rollup. Therefore, your balance will be given in ctez, you’ll transfer ctez, and you’ll pay fees with ctez.

1. Get Ctez tokens from the faucet

The first step is getting ahold of sufficient Ctez tokens on Layer 1, which in this case is Ghostnet. In this tutorial, we use the Tezos address tz1g2RbQtxZRHw8oj4oSnhRzy7iRA2hxU4TD and the Ethereum address 0x8aaD6553Cf769Aa7b89174bE824ED0e53768ed70. All you have to do is replace these with your respective accounts.

For the deployment of the rollup on Ghostnet, we picked this instance of the Ctez contract. To speed up user onboarding, Marigold has integrated support for Ctez in their test network’s faucet.

2. Authorize the Layer 1 bridge to deposit your Ctez tokens

The EVM rollup will accept deposits only from a specific Layer 1 contract, responsible for bridging Ctez tokens to the Layer 2 native tokens, called the Layer 1 bridge.

The Layer 1 bridge needs to be able to transfer Ctez tokens from your account to itself. As the contract is compliant with the FA1.2 specification, we do this by creating a token allowance for the bridge contract, using the %approve entry point:

./octez-client --endpoint https://rpc.ghostnet.teztnets.xyz from fa1.2 contract KT1Q4ecagDAmqiY3ajvtwfNZyChWy86W7pzb as tz1g2RbQtxZRHw8oj4oSnhRzy7iRA2hxU4TD approve <amount-to-deposit> from KT1HJphVV3LUxqZnc7YSH6Zdfd3up1DjLqZv --burn-cap 0.0175

This call will enable the bridge contract to take (up to) <amount-to-deposit> ctez from your account and transfer them to itself, in the next step. Note that the amount should be given in µctez (10-6 ctez), e.g. if you want to deposit 100 ctez, you need to put in 100,000,000 µctez.

3. Deposit your Ctez tokens on Layer 2 via the Layer 1 bridge

The Layer 1 bridge exposes an entrypoint %deposit, enabling users to deposit ctez. The entrypoint takes 3 parameters:

  • The receiver’s EVM address. Note that the user must make sure this is a valid Ethereum address.
  • The amount of ctez to deposit.
  • The maximum fee per unit of gas the sender is willing to pay, in Wei.

You can discover the current gas price by using the RPC eth_gasPrice (note that the result is hex-encoded), e.g.

curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","id":35,"method":"eth_gasPrice","params":[]}' https://evm.ghostnet-evm.tzalpha.net/

After choosing values for the 3 parameters above, you can call the entrypoint %deposit. In this example we’ve set the maximum fee per unit of gas to 21000 Wei:

./octez-client --endpoint https://rpc.ghostnet.teztnets.xyz transfer 0 from tz1g2RbQtxZRHw8oj4oSnhRzy7iRA2hxU4TD to KT1HJphVV3LUxqZnc7YSH6Zdfd3up1DjLqZv --entrypoint "deposit" --arg "Pair (Pair <amount-to-deposit> 0x8aaD6553Cf769Aa7b89174bE824ED0e53768ed70) 21000" --burn-cap 0.1

Using the EVM rollup

We have deployed a Ghostnet instance of Blockscout, a public Ethereum block explorer, which is available at https://explorer.ghostnet-evm.tzalpha.net/. Once you have deposited ctez to your EVM address, you can verify its balance via the explorer, for example: https://explorer.ghostnet-evm.tzalpha.net/address/0x8aaD6553Cf769Aa7b89174bE824ED0e53768ed70.

You are now ready to interact with the EVM rollup, whose public JSON-RPC endpoint lies at https://evm.ghostnet-evm.tzalpha.net. MetaMask is one of the most popular wallets of the Ethereum ecosystem, and below is a quick guide to using it with the EVM rollup deployed on Ghostnet. However, any EVM-compatible wallet should work.

Animation showing how to connect
Metamask with the EVM-rollup on Tezos Ghostnet.

When you have connected your favorite wallet to the EVM rollup and deposited funds, you can start to sign and send transactions via the wallets. You can perform regular transfers between externally-owned (non-contract) accounts:

Animation demonstrating a
transfer of ctez on the Ghostnet EVM-rollup using Metamask.

You can also deploy your own contracts and interact with them. Here is an example of a contract deployed on the EVM rollup.

The EVM rollup is work-in-progress

The EVM rollup is still in alpha, and we are actively working on making it feature complete and bug-free. You can follow the development process directly on the Tezos GitLab repository.

It is subject to frequent upgrades as new features are introduced and existing ones are polished and hardened. However, these updates should not affect end-user activity in the deployed EVM-compatible rollup.

Similarly to Ghostnet’s governance, a dictator key is implemented in the EVM rollup and will be used to migrate the running instance, as future and ongoing developments mature. When we reach the first stable version of the EVM rollup, the dictator key will be removed and replaced by an upgrade mechanism owned by Tezos Layer 1 governance.

If you feel more adventurous and want to try out the latest features of the EVM rollup while they are being developed, it is possible to experiment with the EVM-compatible rollup automatically deployed on the bleeding-edge Dailynet test network. Check out the section ‘EVM Rollup’, and connect your tools with the endpoint: https://evm.dailynet-YYYY-MM-DD.teztnets.xyz.

Join us in creating the best possible EVM experience

To advance the EVM from the current alpha state to a production-ready solution, further testing is needed. We invite you to experiment with the Ghostnet deployment and let us know your experience.

We would also like to hear from Ethereum/Solidity-focused developers interested in deploying their project on an EVM rollup on Tezos. Reach out to us on the Tezos-Dev Slack workspace (in the channel #evm-testnets) and let’s talk about how we can help each other.

Finally, if you’re curious about the rollup-centric future of Tezos, join us at the TezDev developer conference in Paris on July 21 (right after EthCC). This year’s theme is #RiseofRollups. Learn about the future of Tezos, engage with relevant engineers about the EVM roadmap – and witness a live demonstration of 1 million tps!