npm install ethereumjs-tx
const EthereumTx = Transactionconst privateKey = Bufferconst txParams =nonce: '0x00'gasPrice: '0x09184e72a000'gasLimit: '0x2710'to: '0x0000000000000000000000000000000000000000'value: '0x00'data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'// The second parameter is not necessary if these values are usedconst tx = txParams chain: 'mainnet' hardfork: 'petersburg'txconst serializedTx = tx
Chain and Hardfork Support
FakeTransaction constructors receives a second parameter that lets you specify the chain and hardfork
to be used. By default,
petersburg will be used.
There are two ways of customizing these. The first one, as shown in the previous section, is by
using an object with
hardfork names. You can see en example of this in ./examples/ropsten-tx.ts.
The second option is by passing the option
common set to an instance of ethereumjs-common' Common. This is specially useful for custom networks or chains/hardforks not yet supported by
ethereumjs-common. You can see en example of this in ./examples/custom-chain-tx.ts.
MuirGlacier hardfork is supported by the library since the
Support for reduced non-zero call data gas prices from the
(EIP-2028) has been added to the library
along with the
EIP-155 replay protection is activated since the
spuriousDragon hardfork. To disable it, set the
hardfork in the
See our organizational documentation for an introduction to
EthereumJS as well as information on current standards and best practices.
If you want to join for work or do improvements on the libraries have a look at our contribution guidelines.