|
1 | | -# Using EVM-Based Smart Contracts on Linera |
| 1 | +# Using EVM Smart Contracts on Linera |
2 | 2 |
|
3 | | -It is possible to use Ethereum Virtual Machine (EVM)-based smart contracts on |
4 | | -Linera. These contracts are typically written in Solidity. |
| 3 | +Thanks to the experimental integration of |
| 4 | +[`Revm`](https://bluealloy.github.io/revm/) in Linera, it is now possible to run |
| 5 | +smart contracts compiled for the Ethereum Virtual Machine (EVM) within Linera |
| 6 | +microchains. |
5 | 7 |
|
6 | | -EVM smart contracts have access Linera-specific functionality of Linera through |
7 | | -the `Linera.sol` library which exposes necessary interfaces for integration. |
| 8 | +The main purpose of this integration is to allow opensource smart contracts |
| 9 | +originally written for Ethereum to be more easily migrated to the Linera |
| 10 | +protocol and composed with existing Linera applications. |
8 | 11 |
|
9 | | -This allows smart contracts originally deployed on Ethereum to be migrated to |
10 | | -Linera and progressively adapted to Linera’s architecture and features. |
| 12 | +## Overview and code examples |
11 | 13 |
|
12 | | -## Publishing EVM Smart Contracts |
| 14 | +We generally assume that EVM smart contracts are written in |
| 15 | +[Solidity](https://soliditylang.org/) and compiled to EVM bytecode using the |
| 16 | +Solidity compiler. |
| 17 | + |
| 18 | +Transactions running on the EVM are still following the programming model of the |
| 19 | +Linera protocol, notably they can only access the local state of the microchain |
| 20 | +that executes them. Inside a microchain, contracts may call each other as usual, |
| 21 | +possibly across virtual machines. |
| 22 | + |
| 23 | +The main features of Linera, such as cross-chain messaging, are also supported |
| 24 | +in the EVM. These functionalities are exposed through a Solidity library |
| 25 | +[`Linera.sol`](https://github.com/linera-io/linera-protocol/tree/main/linera-execution/solidity/Linera.sol). |
| 26 | + |
| 27 | +Frontends may interact with EVM contracts using custom EVM-like RPCs or using a |
| 28 | +Rust/Wasm application as a proxy. |
| 29 | + |
| 30 | +Code examples for the features described below can be found under the directory |
| 31 | +[`linera-service/tests/fixtures`](https://github.com/linera-io/linera-protocol/tree/main/linera-service/tests/fixtures). |
| 32 | + |
| 33 | +## Publishing EVM smart contracts |
13 | 34 |
|
14 | 35 | The process for publishing EVM smart contracts is similar to that for Wasm smart |
15 | 36 | contracts, with the key difference being the need to specify the virtual machine |
@@ -52,7 +73,7 @@ command: |
52 | 73 |
|
53 | 74 | The serialization code can be generated using the `serde-reflection` crate. |
54 | 75 |
|
55 | | -### Wasm Smart Contracts calling EVM Contracts. |
| 76 | +### Wasm smart contracts calling EVM Contracts. |
56 | 77 |
|
57 | 78 | Wasm smart contracts can call EVM contracts using the `alloy-sol-types` crate. |
58 | 79 | This crate enables construction of Solidity-compatible types and supports RLP |
@@ -93,8 +114,9 @@ Additional SDK functions available include: |
93 | 114 |
|
94 | 115 | ## Difference between EVM applications in Ethereum and Linera. |
95 | 116 |
|
96 | | -- `Reentrancy`: Reentrancy is not supported on Linera. Contracts relying on it |
97 | | - will fail with a clean error. |
| 117 | +- `Reentrancy`: Reentrancy is currently not supported on Linera. Contracts |
| 118 | + relying on it will fail with a clean error. In the future, reentrancy may be |
| 119 | + allowed as an option. |
98 | 120 |
|
99 | 121 | - `Address Computation`: Contract addresses are computed differently from |
100 | 122 | Ethereum. |
|
0 commit comments