this is a JS implemention of the primea hypervisor
npm install primea-hypervisor



A JavaScript Implementation of Primea HyperVisor
npm installjavascriptconst Hypervisor = require('primea-hypervisor')
const {Message, FunctionRef} = require('primea-objects')
const WasmContainer = require('primea-wasm-container')
// setup presistant state
const level = require('level-browserify')
const RadixTree = require('dfinity-radix-tree')
const db = level(
${__dirname}/db)
const tree = new RadixTree({db})const hypervisor = new Hypervisor({tree, containers: [WasmContainer]})
const wasm // a webassembly binary with an exported function named "main"
// create an actor with a webassembly container
const {module} = hypervisor.createActor(WasmContainer.typeId, wasm)
// create message to send to the actor that was just created
const message = new Message({
funcRef: module.getFuncRef('main'),
funcArguments: [new FunctionRef({
actorId: egress.id,
params: ['data']
})]
}).on('execution:error', e => console.error(e))
hypervisor.send(message)
// write everything to the db can create a merkle tree with a single state root
const sr = await hypervisor.createStateRoot()
console.log('state root:', sr.toString('hex'))
``* Performant IPC
* Extensible, allowing for upgrades and customization
* Interoperability with existing codebases
* Deterministic execution
[LICENSE]: https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)