@sec-block/secjs-vmlite

1.0.9 • Public • Published


SecVM

JavaScript Style Guide

Definition: A lite version of SecVM. It is deployed on nodes. It targets to translate bytecode and excute the corresponding operations.

Kind: global class


Install

npm install @sec-block/secjs-vmlite --save 

Usage

let SECVM = require('../src/index.js')

secVm = new SECVM()
secVm.runTrans(opts, cb)

runTrans(opts, cb)

A small function created as there is a lot of sha256 hashing.

Kind: instance method of SecVM

Param Type Description
opts.code Buffer The bytecode of smart contracts' source code
opts.data Buffer The encoded input data -- invoked function name and input variables.
Example
// Please refer to example/example.js
let SECVM = require('../src/index.js')

secVm = new SECVM()
code = '606060...bb0029'
data = 'c6888f...000006'

secVm.runTrans({
  code: Buffer.from(code, 'hex'),
  data: Buffer.from(data, 'hex'),
  gasLimit: Buffer.from('ffffffff', 'hex')
}, function (err, results) {
  console.log('returned: ' + results.vmResults.return.toString('hex'))
  console.log('gasUsed: ' + results.vmResults.gasUsed.toString())
  console.log(err)
})

LICENSE

ISC


SEC轻量级虚拟机-中文简介

该项目是SEC虚拟机的一个轻量级版本。不同于以太坊虚拟机的是,SEC虚拟机运行时并不会对区块链进行更改,从SEC虚拟机中返回的数据会被继续使用进而对区块链产生更改。SEC虚拟机的输入参数应该是智能合约编译后的Bytecode以及编码后的合约调用时的信息和变量。返回值包括合约函数计算的结果(如果该函数有返回值的话),以及计算所要消耗的gas值。

Readme

Keywords

Package Sidebar

Install

npm i @sec-block/secjs-vmlite

Weekly Downloads

1

Version

1.0.9

License

ISC

Unpacked Size

55.7 kB

Total Files

11

Last publish

Collaborators

  • abysmli
  • bi7012xiao
  • feiminhao
  • g277321
  • tornadoming
  • xinnnnn
  • zuweihan1992