Coder Social home page Coder Social logo

evmc-js's Introduction

โ˜”๏ธ๐Ÿ”— EVMC bindings for node.js

This project includes node.js bindings for the Ethereum VM Connector API. It is capable of loading EVM implementations such as aleth-interpreter, evmjit and Hera and enables interop with javascript code.

Usage

Install evmc-js to your project using npm:

npm i evmc

You'll need to extend the provided EVMC class and implement the various abstract function calls. You'll also need to pass the path to the EVMC shared library you're targeting in the constructor. See the unit test for an example, but an abbreviated version of the class would look like:

import {Evmc} from 'evmc';

class MyEVM extends Evmc {

async getAccountExists(account: bigint) {
    // check if account exists and return..
    return doesAccountExists(account);
}

// and so on for all the callbacks...
}

Callbacks can be asynchronous (i.e., return a Promise), or synchronous. See the documentation for full details on the API you need to implement.

When you're ready to execute, you instantiate a instance of your Evmc class and call the execute function using the message and code you with to execute, as below:

const evm = new MyEVM(evmPath);
const result = await evm.execute(message, code));

Execution is asynchronous, but (for now), you should not call execute concurrently. However, you may instantiate multiple EVMs and run them concurrently. Each EVM runs on its own thread outside of the main event loop, so you can take full advantage of the parallelism available on the machine.

Roadmap

Currently, the C part of the binding could use a lot of cleanup and it does have a lot of repetitive code.

In addition, there are a lot of assertions which kill the Node process, which should probably throw an error back to javascript so the error can be handled gracefully.

Tracing is not yet supported, but could be easily added for EVMs with support.

evmc-js's People

Contributors

no2chem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

evmc-js's Issues

Looking for collaborators?

I found myself working on the exact same thing as you have here, and it feels like we could join efforts.

I'd love to have a chat if you have a few minutes to spare at some point soon!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.