What it does

Running ethereum bytecode in eosio smart contract

How I built it

There are two related repositories:

The source code in evm4eosio/evm4eos will used to generate a wasm file named ethereum_vm.wasm that can be deploy to a eosio based network.

The same source code in evm4eosio/evm4eos will also generate a shared library named evm4eos which will used to implement intrinsic functions.

The source code have three API functions:

int evm_execute(const char *raw_trx, size_t raw_trx_size, const char *sender_address, size_t sender_address_size);

int evm_get_account_id(uint64_t account, const char* arbitrary_string, size_t arbitrary_string_size, char* hash, size_t hash_size);

int evm_recover_key(const uint8_t* _sig, uint32_t _sig_size, const uint8_t* _message, uint32_t _message_len, uint8_t* _serialized_public_key, uint32_t _serialized_public_key_size);

evm_execute and evm_get_account_id implemented in evm4eosio/evm4eos/main.cpp

evm_recover_key implemented in evm4eosio/libdevcrypto/Common.cpp

These functions can be configured to implemented as intrinsic functions which can be called by wasm code or compile directly in WASM bytecode with the following cmake variables to improve performance.




The source code of is a fork of eosio source code that have the above three intrinsic function implemented.

Challenges I ran into

Compile EVM source code to WASM

Accomplishments that I'm proud of

Abstracting vm api functions from eosio which allow compile C++ smart contract to native code without changes.

What I learned

Security > Usability > Maintainability > Simplicity > Performance

What's next for evm4eos

Bug Fixes & Continue to improve evm performance and some other things.

Built With

  • aleth
  • boost
  • eosio
  • ethash
  • secp256k1
Share this project:


posted an update

Update smart contract build Instruction


git clone --branch evm2wasm evm4eosio --recursive
cd evm4eosio
mkdir build
cd build

To improve the performance of evm, there are three variables that can be configured to whether use intrinsic evm api or not. These intrinsic EVM API need a nodeos build from eos-with-evm to run.


Build With No Use Of Intrinsic EVM API

cmake ..
make -j$(nproc)

Build To Use Intrinsic EVM API evm_recovery_key

make -j$(nproc)

Build To Use Intrinsic EVM API evm_execute

make -j$(nproc)

Build To Use Intrinsic EVM API evm_get_account_id

make -j$(nproc)

Log in or sign up for Devpost to join the conversation.