How to use the ethereumjs-vm/dist/hooked.fromWeb3Provider function in ethereumjs-vm

To help you get started, we’ve selected a few ethereumjs-vm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / truffle / packages / sawtooth-seth-provider / src / subproviders / vm.js View on Github external
VmSubprovider.prototype.runVm = function(payload, cb) {
  const self = this;

  var blockData = self.currentBlock;
  var block = blockFromBlockData(blockData);
  var blockNumber = ethUtil.addHexPrefix(blockData.number.toString("hex"));

  // create vm with state lookup intercepted
  var vm = (self.vm = createVm(self.engine, blockNumber, {
    enableHomestead: true
  }));

  if (self.opts.debug) {
    vm.on("step", function(data) {
      console.log(data.opcode.name);
    });
  }

  // create tx
  var txParams = payload.params[0];
  // console.log('params:', payload.params)

  const normalizedTxParams = {
    to: txParams.to ? ethUtil.addHexPrefix(txParams.to) : undefined,
    from: txParams.from ? ethUtil.addHexPrefix(txParams.from) : undefined,
github MetaMask / web3-provider-engine / subproviders / vm.js View on Github external
VmSubprovider.prototype.runVm = function(payload, cb){
  const self = this

  var blockData = self.currentBlock
  var block = blockFromBlockData(blockData)
  var blockNumber = ethUtil.addHexPrefix(blockData.number.toString('hex'))

  // create vm with state lookup intercepted
  var vm = self.vm = createVm(self.engine, blockNumber, {
    enableHomestead: true
  })

  if (self.opts.debug) {
    vm.on('step', function (data) {
      console.log(data.opcode.name)
    })
  }

  // create tx
  var txParams = payload.params[0]
  // console.log('params:', payload.params)

  const normalizedTxParams = {
    to: txParams.to ? ethUtil.addHexPrefix(txParams.to) : undefined,
    from: txParams.from ? ethUtil.addHexPrefix(txParams.from) : undefined,
github MetaMask / eth-json-rpc-middleware / vm.js View on Github external
function runVm (req, block, cb) {
    const txParams = Object.assign({}, req.params[0])
    const blockRef = req.params[1]
    // opting to use blockRef as specified
    // instead of hardening to resolved block's number
    // for compatiblity with eth-json-rpc-ipfs
    // const blockRef = block.number.toNumber()

    // create vm with state lookup intercepted
    const vm = createVm(provider, blockRef, {
      enableHomestead: true
    })

    // create tx
    txParams.from = txParams.from || '0x0000000000000000000000000000000000000000'
    txParams.gasLimit = txParams.gasLimit || ('0x' + block.header.gasLimit.toString('hex'))
    const tx = new FakeTransaction(txParams)

    vm.runTx({
      tx: tx,
      block: block,
      skipNonce: true,
      skipBalance: true
    }, function (err, results) {
      if (err) return cb(err)
      if (results.error) {

ethereumjs-vm

An Ethereum VM implementation

MPL-2.0
Latest version published 4 years ago

Package Health Score

61 / 100
Full package analysis