npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-revm

v0.1.4

Published

JS wrapper and bindings for the EVM implemented in Rust

Downloads

52

Readme

js-revm

Super fast JS bindings to revm

What

Use the EVM implemented in Rust in your JS projects by simply installing an npm module

  • Extremely simple to use
  • Extremely fast

Tooling

This project uses neon as a core dependency

Usage

Install the npm pacakge (version should be >= 0.1.2)

npm i js-revm

Example Usage

*You can find more examples under the examples folder.

const Revm = require("js-revm");

function main() {
  const evm = new Revm(); // defaults to latest
  const addr = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";

  // get new balance.
  const bal = evm.getBalance(addr);
  console.log("bal ->", bal);

  // set balance.
  evm.setBalance(addr, 1e18);
  console.log("new bal ->", evm.getBalance(addr));

  // tx.
  const from = addr;
  const to = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";
  console.log("balance to before ->", evm.getBalance(to));
  const gasLimit = 21000;
  const gasPrice = 0;
  const value = 1111;
  const txData = "";

  const txOpts = {
    from,
    to,
    value,
    gasLimit,
    gasPrice,
    txData,
  };

  // execute the tx and commit it.
  const result = evm.callCommit(txOpts);
  console.log(result);

  console.log("balance post tx ->", evm.getBalance(to));
}

main();

API

For now, JS-REVM comes with 4 public functions

1. getBalance(addr)

Returns the balance of the address

2. setBalance(address, amount)

Sets a new balance to the address, amount in WEI

3. callCommit(txOpts)

Executes a transaction and commits it to the memory db created by default.

txOpts:

  • from: The address executing the transaction (defaults to address(0))
  • to: The destination address (empty for contract creation)
  • value: Amount in WEI (defaults to 0)
  • txData: Transaction data or bytecode for contract creation
  • gasLimit: Gas limit for the executing transaction (defaults to 30_000_000)
  • gasPrice: Gas price for the transaction (defaults to 0)

Result

The tx returns an object with some key properties depending on the transaction (contract_created for new contract creation, error reason if reverted, etc.)

4. callNoCommit(txOpts)

Same as callCommit but it executes the transaction without committing it to the db

Config

The EVM can be configured to any desired version, it defaults to the latest.

Example

function main() {
  const config = {
    specId: "London",
  };

  const evm = new Revm(config);
}

Benchmark