Skip to content

Latest commit

 

History

History
294 lines (187 loc) · 9.05 KB

index.md

File metadata and controls

294 lines (187 loc) · 9.05 KB

Table of Contents

vm.runBlockchain

Processes blocks and adds them to the blockchain

Parameters

vm.runBlock

Processes the block running all of the transactions it contains and updating the miner's account

Parameters

  • opts
    • opts.block Block the Block to process
    • opts.generate Boolean [gen=false] whether to generate the stateRoot, if false runBlock will check the stateRoot of the block against the Trie
  • cb runBlock~callback callback

runBlock~callback

Callback for runBlock method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • results Object
    • results.receipts Array the receipts from the transactions in the block
    • results.results Array

runTx~callback

Callback for runTx method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • results Object
    • results.amountSpent BN the amount of ether used by this transaction as a bignum
    • results.gasUsed BN the amount of gas as a bignum used by the transaction
    • results.gasRefund BN the amount of gas as a bignum that was refunded during the transaction (i.e. gasUsed = totalGasConsumed - gasRefund)
  • vm VM contains the results from running the code, if any, as described in vm.runCode(params, cb)

vm.runTx

Process a transaction. Run the vm. Transfers eth. Checks balances.

Parameters

  • opts
    • opts.tx Transaction a Transaction to run
    • opts.skipNonce Boolean skips the nonce check
    • opts.skipBalance Boolean skips the balance check
    • opts.block Block the block to which the tx belongs, if no block is given a default one is created
  • cb runTx~callback the callback

VM

VM Class, new VM(opts) creates a new VM object

Parameters

  • opts Object
    • opts.stateManager StateManager a StateManager instance to use as the state store (Beta API)
    • opts.state Trie a merkle-patricia-tree instance for the state tree (ignored if stateManager is passed)
    • opts.blockchain Blockchain a blockchain object for storing/retrieving blocks (ignored if stateManager is passed)
    • opts.chain (String | Number) the chain the VM operates on [default: 'mainnet']
    • opts.hardfork String hardfork rules to be used [default: 'petersburg', supported: 'byzantium', 'constantinople', 'petersburg' (will throw on unsupported)]
    • opts.activatePrecompiles Boolean create entries in the state tree for the precompiled contracts
    • opts.allowUnlimitedContractSize Boolean allows unlimited contract sizes while debugging. By setting this to true, the check for contract size limit of 24KB (see EIP-170) is bypassed. (default: false; ONLY set to true during debugging)
    • opts.emitFreeLogs Boolean Changes the behavior of the LOG opcode, the gas cost of the opcode becomes zero and calling it using STATICCALL won't throw. (default: false; ONLY set to true during debugging)

vm.runCode

Runs EVM code

Parameters

  • opts Object
    • opts.account Account the Account that the executing code belongs to. If omitted an empty account will be used
    • opts.address Buffer the address of the account that is executing this code. The address should be a Buffer of bytes. Defaults to 0
    • opts.block Block the Block the tx belongs to. If omitted a blank block will be used
    • opts.caller Buffer the address that ran this code. The address should be a Buffer of 20bits. Defaults to 0
    • opts.code Buffer the EVM code to run given as a Buffer
    • opts.data Buffer the input data
    • opts.gasLimit Buffer the gas limit for the code
    • opts.origin Buffer the address where the call originated from. The address should be a Buffer of 20bits. Defaults to 0
    • opts.value Buffer the value in ether that is being sent to opt.address. Defaults to 0
    • opts.pc Number the initial program counter. Defaults to 0
  • cb runCode~callback callback

runCode~callback

Callback for runCode method

Type: Function

Parameters

  • error Error an error that may have happened or null
  • results Object
    • results.gas BN the amount of gas left
    • results.gasUsed BN the amount of gas as a bignum the code used to run
    • results.gasRefund BN a bignum containing the amount of gas to refund from deleting storage values
    • results.selfdestruct Object an Object with keys for accounts that have selfdestructed and values for balance transfer recipient accounts
    • results.logs Array an Array of logs that the contract emitted
    • results.exception Number 0 if the contract encountered an exception, 1 otherwise
    • results.exceptionError String a String describing the exception if there was one
    • results.return Buffer a Buffer containing the value that was returned by the contract

Event: beforeBlock

The beforeBlock event

Type: Object

Properties

  • block Block emits the block that is about to be processed

Event: afterBlock

The afterBlock event

Type: Object

Properties

  • result Object emits the results of processing a block

Event: beforeTx

The beforeTx event

Type: Object

Properties

  • tx Transaction emits the Transaction that is about to be processed

Event: afterTx

The afterTx event

Type: Object

Properties

  • result Object result of the transaction

Event: step

The step event for trace output

Type: Object

Properties

  • pc Number representing the program counter
  • opcode String the next opcode to be ran
  • gasLeft BN amount of gasLeft
  • stack Array an Array of Buffers containing the stack
  • account Account the Account which owns the code running
  • address Buffer the address of the account
  • depth Number the current number of calls deep the contract is
  • memory Buffer the memory of the VM as a buffer
  • memoryWordCount BN current size of memory in words
  • stateManager StateManager a StateManager instance (Beta API)