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

sophonjs-vm

v2.6.0

Published

An Sophon VM implementation

Downloads

10

Readme

SYNOPSIS

NPM Package Build Status Coverage Status Gitter or #sophonjs on freenode

js-standard-style

Implements Sophon's VM in Javascript.

Fork Support

The VM (v2.6.x release series) currently supports the following hardforks (default: Byzantium):

  • Byzantium
  • Constantinople
  • Petersburg

Parallel HF support was introduced in the v2.5.0 release, if you want some background have a look at the respective release notes.

If you are still looking for a Spurious Dragon compatible version of this library install the latest of the 2.2.x series (see Changelog).

INSTALL

npm install sophonjs-vm

USAGE

var VM = require('sophonjs-vm')

//create a new VM instance
var vm = new VM()
var code = '7f4e616d65526567000000000000000000000000000000000000000000000000003055307f4e616d6552656700000000000000000000000000000000000000000000000000557f436f6e666967000000000000000000000000000000000000000000000000000073661005d2720d855f1d9976f88bb10c1a3398c77f5573661005d2720d855f1d9976f88bb10c1a3398c77f7f436f6e6669670000000000000000000000000000000000000000000000000000553360455560df806100c56000396000f3007f726567697374657200000000000000000000000000000000000000000000000060003514156053576020355415603257005b335415603e5760003354555b6020353360006000a233602035556020353355005b60007f756e72656769737465720000000000000000000000000000000000000000000060003514156082575033545b1560995733335460006000a2600033545560003355005b60007f6b696c6c00000000000000000000000000000000000000000000000000000000600035141560cb575060455433145b1560d25733ff5b6000355460005260206000f3'

vm.runCode({
  code: Buffer.from(code, 'hex'), // code needs to be a Buffer
  gasLimit: Buffer.from('ffffffff', 'hex')
}, function(err, results){
  console.log('returned: ' + results.return.toString('hex'));
})

Also more examples can be found here

BROWSER

To build for standalone use in the browser, install browserify and check run-transactions-simple example. This will give you a global variable SofVM to use. The generated file will be at ./examples/run-transactions-simple/build.js.

API

VM

For documentation on VM instantiation, exposed API and emitted events see generated API docs.

StateManger

The API for the StateManager is currently in Beta, separate documentation can be found here.

The StateManager API has been largely reworked recently and the StateManager will be removed from the VM and provided as a separate package in a future v3.0.0 release, see release notes for the v2.5.0 VM release for further details.

Internal Structure

The VM processes state changes at many levels.

  • runBlockchain
    • for every block, runBlock
  • runBlock
    • for every tx, runTx
    • pay miner and uncles
  • runTx
    • check sender balance
    • check sender nonce
    • runCall
    • transfer gas charges
  • runCall
    • checkpoint state
    • transfer value
    • load code
    • runCode
    • materialize created contracts
    • revert or commit checkpoint
  • runCode
    • iterate over code
    • run op codes
    • track gas usage
  • OpFns
    • run individual op code
    • modify stack
    • modify memory
    • calculate fee

The opFns for CREATE, CALL, and CALLCODE call back up to runCall.

DEVELOPMENT

Developer documentation - currently mainly with information on testing and debugging - can be found here.

LICENSE

MPL-2.0