7 stable releases

9.0.0 Jul 28, 2021
8.0.0 Jul 28, 2021
7.5.0 Mar 24, 2021
7.4.0 Jun 24, 2020
7.1.0 Dec 4, 2019

#4 in #evmc

Download history 5/week @ 2024-02-18 4/week @ 2024-02-25 117/week @ 2024-03-31

117 downloads per month

Apache-2.0

55KB
1K SLoC

evmc-declare

This is a Rust interface to EVMC.

This crate contains a declare macro for easily creating EVMC compatible VM implementations.


lib.rs:

evmc-declare is an attribute-style procedural macro to be used for automatic generation of FFI code for the EVMC API with minimal boilerplate.

evmc-declare can be used by applying its attribute to any struct which implements the EvmcVm trait, from the evmc-vm crate.

The macro takes three arguments: a valid UTF-8 stylized VM name, a comma-separated list of capabilities, and a version string.

Example

#[evmc_declare::evmc_declare_vm("This is an example VM name", "ewasm, evm", "1.2.3-custom")]
pub struct ExampleVM;

impl evmc_vm::EvmcVm for ExampleVM {
    fn init() -> Self {
            ExampleVM {}
    }

    fn execute(&self, revision: evmc_vm::ffi::evmc_revision, code: &[u8], message: &evmc_vm::ExecutionMessage, context: Option<&mut evmc_vm::ExecutionContext>) -> evmc_vm::ExecutionResult {
            evmc_vm::ExecutionResult::success(1337, None)
    }
}

Dependencies

~1.6–3.5MB
~75K SLoC