- vm.runBlockchain
- VM
- vm.runBlock
- runBlock~callback
- runTx~callback
- vm.runTx
- runCode~callback
- vm.runCode
- Event: beforeBlock
- Event: afterBlock
- Event: beforeTx
- Event: afterTx
- Event: step
Processes blocks and adds them to the blockchain
blockchain
Blockchain A blockchain that to processcb
Function the callback function
VM Class, new VM(opts)
creates a new VM object
opts
Objectopts.stateManager
StateManager aStateManager
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: 'byzantium', supported: 'byzantium', 'constantinople', 'petersburg' (will throw on unsupported)]opts.activatePrecompiles
Boolean create entries in the state tree for the precompiled contractsopts.allowUnlimitedContractSize
Boolean allows unlimited contract sizes while debugging. By setting this totrue
, the check for contract size limit of 24KB (see EIP-170) is bypassed. (default:false
; ONLY set totrue
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 totrue
during debugging)
Processes the block
running all of the transactions it contains and updating the miner's account
opts
cb
runBlock~callback callback
Callback for runBlock
method
Type: Function
Callback for runTx
method
Type: Function
error
Error an error that may have happened ornull
results
Objectresults.amountSpent
BN the amount of ether used by this transaction as abignum
results.gasUsed
BN the amount of gas as abignum
used by the transactionresults.gasRefund
BN the amount of gas as abignum
that was refunded during the transaction (i.e.gasUsed = totalGasConsumed - gasRefund
)
vm
VM contains the results from running the code, if any, as described invm.runCode(params, cb)
Process a transaction. Run the vm. Transfers eth. Checks balances.
opts
opts.tx
Transaction aTransaction
to runopts.skipNonce
Boolean skips the nonce checkopts.skipBalance
Boolean skips the balance checkopts.block
Block the block to which thetx
belongs, if no block is given a default one is created
cb
runTx~callback the callback
Callback for runCode
method
Type: Function
error
Error an error that may have happened ornull
results
Objectresults.gas
BN the amount of gas leftresults.gasUsed
BN the amount of gas as abignum
the code used to runresults.gasRefund
BN abignum
containing the amount of gas to refund from deleting storage valuesresults.selfdestruct
Object anObject
with keys for accounts that have selfdestructed and values for balance transfer recipient accountsresults.logs
Array anArray
of logs that the contract emittedresults.exception
Number0
if the contract encountered an exception,1
otherwiseresults.exceptionError
String aString
describing the exception if there was oneresults.return
Buffer aBuffer
containing the value that was returned by the contract
Runs EVM code
opts
Objectopts.account
Account theAccount
that the executing code belongs to. If omitted an empty account will be usedopts.address
Buffer the address of the account that is executing this code. The address should be aBuffer
of bytes. Defaults to0
opts.block
Block theBlock
thetx
belongs to. If omitted a blank block will be usedopts.caller
Buffer the address that ran this code. The address should be aBuffer
of 20bits. Defaults to0
opts.code
Buffer the EVM code to run given as aBuffer
opts.data
Buffer the input dataopts.gasLimit
Buffer the gas limit for the codeopts.origin
Buffer the address where the call originated from. The address should be aBuffer
of 20bits. Defaults to0
opts.value
Buffer the value in ether that is being sent toopt.address
. Defaults to0
opts.pc
Number the initial program counter. Defaults to0
cb
runCode~callback callback
The beforeBlock
event
Type: Object
block
Block emits the block that is about to be processed
The afterBlock
event
Type: Object
result
Object emits the results of processing a block
The beforeTx
event
Type: Object
tx
Transaction emits the Transaction that is about to be processed
The afterTx
event
Type: Object
result
Object result of the transaction
The step
event for trace output
Type: Object
pc
Number representing the program counteropcode
String the next opcode to be rangasLeft
BN amount of gasLeftstack
Array anArray
ofBuffers
containing the stackaccount
Account theAccount
which owns the code runningaddress
Buffer the address of theaccount
depth
Number the current number of calls deep the contract ismemory
Buffer the memory of the VM as abuffer
memoryWordCount
BN current size of memory in wordsstateManager
StateManager aStateManager
instance (Beta API)