ethereumjs-vm

  • Version 4.2.0
  • Published
  • 484 kB
  • 15 dependencies
  • MPL-2.0 license

Install

npm i ethereumjs-vm
yarn add ethereumjs-vm
pnpm add ethereumjs-vm

Overview

An Ethereum VM implementation

Index

Variables

variable AsyncEventEmitter

const AsyncEventEmitter: any;

    Classes

    class VM

    class VM extends AsyncEventEmitter {}
    • Execution engine which can be used to run a blockchain, individual blocks, individual transactions, or snippets of EVM bytecode.

      This class is an AsyncEventEmitter, please consult the README to learn how to use it.

    constructor

    constructor(opts?: VMOpts);
    • Instantiates a new [[VM]] Object.

      Parameter opts

      Default values for the options are: - chain: 'mainnet' - hardfork: 'petersburg' [supported: 'byzantium', 'constantinople', 'petersburg', 'istanbul' (DRAFT) (will throw on unsupported)] - activatePrecompiles: false - allowUnlimitedContractSize: false [ONLY set to true during debugging]

    property allowUnlimitedContractSize

    allowUnlimitedContractSize: boolean;

      property blockchain

      blockchain: Blockchain;

        property opts

        opts: VMOpts;

          property pStateManager

          readonly pStateManager: PStateManager;

            property stateManager

            stateManager: StateManager;

              method copy

              copy: () => VM;
              • Returns a copy of the [[VM]] instance.

              method runBlock

              runBlock: (opts: RunBlockOpts) => Promise<RunBlockResult>;
              • Processes the block running all of the transactions it contains and updating the miner's account

                This method modifies the state. If generate is true, the state modifications will be reverted if an exception is raised. If it's false, it won't revert if the block's header is invalid. If an error is thrown from an event handler, the state may or may not be reverted.

                Parameter opts

                Default values for options: - generate: false

              method runBlockchain

              runBlockchain: (blockchain: any) => Promise<void>;
              • Processes blocks and adds them to the blockchain.

                This method modifies the state.

                Parameter blockchain

                A [blockchain](https://github.com/ethereum/ethereumjs-blockchain) object to process

              method runCall

              runCall: (opts: RunCallOpts) => Promise<EVMResult>;
              • runs a call (or create) operation.

                This method modifies the state.

              method runCode

              runCode: (opts: RunCodeOpts) => Promise<ExecResult>;
              • Runs EVM code.

                This method modifies the state.

              method runTx

              runTx: (opts: RunTxOpts) => Promise<RunTxResult>;
              • Process a transaction. Run the vm. Transfers eth. Checks balances.

                This method modifies the state. If an error is thrown, the modifications are reverted, except when the error is thrown from an event handler. In the latter case the state may or may not be reverted.

              Interfaces

              interface VMOpts

              interface VMOpts {}
              • Options for instantiating a [[VM]].

              property activatePrecompiles

              activatePrecompiles?: boolean;
              • If true, create entries in the state tree for the precompiled contracts, saving some gas the first time each of them is called.

                If this parameter is false, the first call to each of them has to pay an extra 25000 gas for creating the account.

                Setting this to true has the effect of precompiled contracts' gas costs matching mainnet's from the very first call, which is intended for testing networks.

              property allowUnlimitedContractSize

              allowUnlimitedContractSize?: boolean;
              • Allows unlimited contract sizes while debugging. By setting this to true, the check for contract size limit of 24KB (see [EIP-170](https://git.io/vxZkK)) is bypassed

              property blockchain

              blockchain?: Blockchain;
              • A [blockchain](https://github.com/ethereumjs/ethereumjs-blockchain) object for storing/retrieving blocks

              property chain

              chain?: string;
              • The chain the VM operates on

              property common

              common?: Common;

                property hardfork

                hardfork?: string;
                • Hardfork rules to be used

                property state

                state?: any;
                • A [merkle-patricia-tree](https://github.com/ethereumjs/merkle-patricia-tree) instance for the state tree (ignored if stateManager is passed)

                  Deprecated

                property stateManager

                stateManager?: StateManager;
                • A [[StateManager]] instance to use as the state store (Beta API)

                Package Files (1)

                Dependencies (15)

                Dev Dependencies (32)

                Peer Dependencies (0)

                No peer dependencies.

                Badge

                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ethereumjs-vm.

                • Markdown
                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ethereumjs-vm)
                • HTML
                  <a href="https://www.jsdocs.io/package/ethereumjs-vm"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>