{"_id":"@asanrom/besu-pq-tx","_rev":"1-2ee075b83516a509bb01fd67882b8fe8","name":"@asanrom/besu-pq-tx","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@asanrom/besu-pq-tx","version":"1.0.0","description":"Modified version of @ethreum/tx for post quantum signature algorithm.","homepage":"https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#readme","repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-monorepo.git"},"license":"MPL-2.0","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"prebuild":"npm run lint","compile":"tsc --pretty --declaration","build":"rimraf dist && npm run compile","lint":"eslint --fix src/**/*.ts","test":"env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/*.ts'","gendoc":"typedoc --out docs ./src"},"dependencies":{"@asanrom/dilithium":"1.1.0","@ethereumjs/common":"^3.0.0","@ethereumjs/rlp":"^4.0.0","@ethereumjs/util":"^8.0.0","ethereum-cryptography":"^1.1.2"},"devDependencies":{"@types/chai":"4.3.3","@types/mocha":"9.1.1","@types/node":"18.7.14","@typescript-eslint/eslint-plugin":"5.36.1","@typescript-eslint/parser":"5.36.1","chai":"4.3.6","eslint":"8.23.0","mocha":"10.0.0","rimraf":"3.0.2","ts-loader":"9.3.1","ts-node":"10.9.1","typedoc":"0.23.12","typescript":"4.8.2"},"engines":{"node":">=14"},"gitHead":"86aa17bec9b64c65fd0aa99bbe94402145eea083","bugs":{"url":"https://github.com/ethereumjs/ethereumjs-monorepo/issues"},"_id":"@asanrom/besu-pq-tx@1.0.0","_nodeVersion":"14.17.5","_npmVersion":"8.5.5","dist":{"integrity":"sha512-dPm9+/hvqhD4+kT1HNDVm3bg3dsW4nVYcciBhug+bSKqZojJsI0EPwLoAtY9UXCYpQ4b5+Js3MlZFNa6NqY5Ew==","shasum":"d34a18c69ca6704a426e664c28c5644998975a13","tarball":"https://registry.npmjs.org/@asanrom/besu-pq-tx/-/besu-pq-tx-1.0.0.tgz","fileCount":27,"unpackedSize":203232,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOVffUzQX2oRVXTblzlkPjymrTXoUg4voR9CiWOobWXwIgMvRITFdle4ssYMaWdi9cpTjk3l4Ech4bcOgk97k8NKQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKuR1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqbMA/+NYigTMwoo0tpVrn6ALeY2yc/wHecnLO/om8x432J7+M1v1t2\r\nC0GVuOTxW5IAG9z7k7LloBsFUJz+g4/LBU6u8Nyl1PUL1qSDzk3hu0VITK97\r\n3Mx2GPUNIvPjfAHAxoWIGXEm/uZylR3MCYZJG6a/p+z0VFzH/e/4STGDJg2Y\r\nB3bSLYtW5KLDiqOtFnICfNBeuI4s1Fgaa+WX9NuMn6/TESIBHjLVZCMTpgFk\r\ndCG8cvUc+R9GuQ06LKe9hGxQB55Pop1lZESRwOx0/ybBM8Ll6dRK4UzvaZqS\r\n5vi9N9lMcwGxaN1KMdyRm7VRaYw2yfn6nB7L3D2BhHWSeHZEd/DWLN7fxSuI\r\ncg2B68yiN3WAWn/iQ0k4A+S8MZAHjdEaAIIFW+PS5fRGJ4oO+4DeCaqAYxcO\r\n+RUXpspb7uXo8nrWQQ3+vrB63YSVesxXqvngqzmE4jmd2M8x9+gmV8bk++Xd\r\nmHiQeKDZg96ejISNC4nboLiQJts2rGNMSG0gsT8ouVRP9HREYpU7MjzyJ6sF\r\n/6+bfBFEsFUqT/1HVbnKVEDMyiqBOmyGOqn5np4DBEH3uy86S+MDDhCrVpRR\r\nBkczcRR7YBqhOf2Ig3mf8GAk3KxbEbO7cJaLrMbaVAGvkJJM6rvlVgQ06Yd6\r\nyw8aDczc7sUB7rn1er2TJguW+91AMRTlCTw=\r\n=qEdD\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asanrom","email":"agustinsanromanguzman@gmail.com"},"directories":{},"maintainers":[{"name":"asanrom","email":"agustinsanromanguzman@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/besu-pq-tx_1.0.0_1663755381369_0.20201248182372922"},"_hasShrinkwrap":false},"1.0.1":{"name":"@asanrom/besu-pq-tx","version":"1.0.1","description":"Modified version of @ethreum/tx for post quantum signature algorithm.","homepage":"https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#readme","repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-monorepo.git"},"license":"MPL-2.0","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"prebuild":"npm run lint","compile":"tsc --pretty --declaration","build":"rimraf dist && npm run compile","lint":"eslint --fix src/**/*.ts","test":"env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/*.ts'","gendoc":"typedoc --out docs ./src"},"dependencies":{"@asanrom/dilithium":"1.1.0","@ethereumjs/common":"^3.0.0","@ethereumjs/rlp":"^4.0.0","@ethereumjs/util":"^8.0.0","ethereum-cryptography":"^1.1.2"},"devDependencies":{"@types/chai":"4.3.3","@types/mocha":"9.1.1","@types/node":"18.7.14","@typescript-eslint/eslint-plugin":"5.36.1","@typescript-eslint/parser":"5.36.1","chai":"4.3.6","eslint":"8.23.0","mocha":"10.0.0","rimraf":"3.0.2","ts-loader":"9.3.1","ts-node":"10.9.1","typedoc":"0.23.12","typescript":"4.8.2"},"engines":{"node":">=14"},"gitHead":"28e9fdeef45dc46fcc5eb97856df17211607cf88","bugs":{"url":"https://github.com/ethereumjs/ethereumjs-monorepo/issues"},"_id":"@asanrom/besu-pq-tx@1.0.1","_nodeVersion":"14.17.5","_npmVersion":"8.5.5","dist":{"integrity":"sha512-/SXwHeV3UrpLA+EcqOjf4euCAP9DmK2ATg0O2kPCONqISQlspzIoBOG9avi99n0ZXdF1RIs0ZvexCasEia9PPA==","shasum":"791bde8c31baaeca011fb760ff3b8d4da89f65dc","tarball":"https://registry.npmjs.org/@asanrom/besu-pq-tx/-/besu-pq-tx-1.0.1.tgz","fileCount":27,"unpackedSize":203911,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDZkdbr3dyBnOXLVow38E8d/y2wZvmz8dYVk91wYiyYfAiEA09hkKP8qG39iFaFYcxZGiLW3PY+iBK6vuJQ5FhZvUnk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKvnnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoDxBAAivlZXrXjOHf/pG+jY0sOLVzWfRYdJXQlCizVWHz3BiWTW5S1\r\n1KjFM84Lju/rORgnmPRQHgMS3zDtIWMU1nWVx5Icj4E5z5/9X+PoLqmSBHfw\r\nXlo0P2bavS7MENi9O9EQyJkXNHc+4GPxPUZreb+vmPL3GsXuRI0ygEj+GN+K\r\nAj0P6uObEvTU81uXfX/EiJ0nzLZIsFzZZFiaj8rs6kLNHf0Ffm7kc6LTCCDy\r\nCZIsjsU3BAU7NP9dIXxDrilK1IFSZ0yE8nH0tbQFXA7hHV0jAtd/PQ7WsjA8\r\n+fs6sjW9GnK//orF8MqEhmzqqjoKsa+tjYT0IAdsrhE4DixDPwJfj3dqX3oy\r\nsLmq+OuqE1TZ9/gzKfVEVfkJn6uQWiQwn1GlUgvSs7Rxmiw7FdtBM3EAU8zs\r\n02BtNiEQP1X7vzxpib44Ef30hFC4f/Kdq7yCd1q2KwBBKzqsoU8+DWU1vQe5\r\ngZw7iowjf5JfHPs2HZfFZuR4s2QrpIf7k0eHUtkOR/UTOY1jrMJTf5B5qSm5\r\nhJxfYQNN2MM4JncAauCFF6z+J3Nm7hyn1ZFzdoTN1kGh+mR3RvsmWCbbTEfe\r\nDZw4yjaLB4ZnRU9eIlEqVGeOwlgudW9570up5ReKYAXJj6f6XLIN0EF3TvLq\r\nkj4jGVgeluQKMt2ebhiNXU4lgTARJVoTJoA=\r\n=OGOT\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"asanrom","email":"agustinsanromanguzman@gmail.com"},"directories":{},"maintainers":[{"name":"asanrom","email":"agustinsanromanguzman@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/besu-pq-tx_1.0.1_1663760870954_0.08353711709245171"},"_hasShrinkwrap":false}},"time":{"created":"2022-09-21T10:16:21.287Z","1.0.0":"2022-09-21T10:16:21.536Z","modified":"2022-09-21T11:47:51.212Z","1.0.1":"2022-09-21T11:47:51.139Z"},"maintainers":[{"name":"asanrom","email":"agustinsanromanguzman@gmail.com"}],"description":"Modified version of @ethreum/tx for post quantum signature algorithm.","homepage":"https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#readme","repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-monorepo.git"},"bugs":{"url":"https://github.com/ethereumjs/ethereumjs-monorepo/issues"},"license":"MPL-2.0","readme":"# @ethereumjs/tx\r\n\r\n[![NPM Package][tx-npm-badge]][tx-npm-link]\r\n[![GitHub Issues][tx-issues-badge]][tx-issues-link]\r\n[![Actions Status][tx-actions-badge]][tx-actions-link]\r\n[![Code Coverage][tx-coverage-badge]][tx-coverage-link]\r\n[![Discord][discord-badge]][discord-link]\r\n\r\n| Implements schema and functions related to Ethereum's transaction. |\r\n| ------------------------------------------------------------------ |\r\n\r\nNote: this `README` reflects the state of the library from `v3.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-tx) for an introduction on the last preceding release.\r\n\r\n## Installation\r\n\r\nTo obtain the latest version, simply require the project using `npm`:\r\n\r\n```shell\r\nnpm install @ethereumjs/tx\r\n```\r\n\r\n## Usage\r\n\r\n### Static Constructor Methods\r\n\r\nTo instantiate a tx it is not recommended to use the constructor directly. Instead each tx type comes with the following set of static constructor methods which helps on instantiation depending on the input data format:\r\n\r\n- `public static fromTxData(txData: TxData, opts: TxOptions = {})`: instantiate from a data dictionary\r\n- `public static fromSerializedTx(serialized: Buffer, opts: TxOptions = {})`: instantiate from a serialized tx\r\n- `public static fromValuesArray(values: Buffer[], opts: TxOptions = {})`: instantiate from a values array\r\n\r\nSee one of the code examples on the tx types below on how to use.\r\n\r\nAll types of transaction objects are frozen with `Object.freeze()` which gives you enhanced security and consistency properties when working with the instantiated object. This behavior can be modified using the `freeze` option in the constructor if needed.\r\n\r\n### Chain and Hardfork Support\r\n\r\nThe `Transaction` constructor receives a parameter of an [`@ethereumjs/common`](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/common) object that lets you specify the chain and hardfork to be used. If there is no `Common` provided the chain ID provided as a paramter on typed tx or the chain ID derived from the `v` value on signed EIP-155 conforming legacy txs will be taken (introduced in `v3.2.1`). In other cases the chain defaults to `mainnet`.\r\n\r\nBase default HF (determined by `Common`): `merge`\r\n\r\nStarting with `v3.2.1` the tx library now deviates from the default HF for typed tx using the following rule: \"The default HF is the default HF from `Common` if the tx type is active on that HF. Otherwise it is set to the first greater HF where the tx is active.\"\r\n\r\nSupported Hardforks:\r\n\r\n| Hardfork         | Introduced | Description                                                                                             |\r\n| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------- |\r\n| `london`         | `v3.2.0`   | `EIP-1559` Transactions                                                                                 |\r\n| `berlin`         | `v3.1.0`   |  `EIP-2718` Typed Transactions, Optional Access Lists Tx Type `EIP-2930`                                |\r\n| `muirGlacier`    |  `v2.1.2`  |  -                                                                                                      |\r\n| `istanbul`       |  `v2.1.1`  | Support for reduced non-zero call data gas prices ([EIP-2028](https://eips.ethereum.org/EIPS/eip-2028)) |\r\n| `spuriousDragon` |  `v2.0.0`  |  `EIP-155` replay protection (disable by setting HF pre-`spuriousDragon`)                               |\r\n\r\n### Standalone EIPs\r\n\r\nThe following \"standalone\" EIPs are supported by the library can be manually activated using a respectively initialized `Common` instance, e.g.:\r\n\r\n```typescript\r\nconst common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London, eips: [3860] })\r\n```\r\n\r\n- [EIP-3860](https://eips.ethereum.org/EIPS/eip-3855): Limit and meter initcode (`experimental`)\r\n\r\n### Transaction Types\r\n\r\nThis library supports the following transaction types ([EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)):\r\n\r\n- `FeeMarketEIP1559Transaction` ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559), gas fee market)\r\n- `AccessListEIP2930Transaction` ([EIP-2930](https://eips.ethereum.org/EIPS/eip-2930), optional access lists)\r\n- `Transaction`, the Ethereum standard tx up to `berlin`, now referred to as legacy txs with the introduction of tx types\r\n\r\n#### Gas Fee Market Transactions (EIP-1559)\r\n\r\n- Class: `FeeMarketEIP1559Transaction`\r\n- Activation: `london`\r\n- Type: `2`\r\n\r\nThis is the recommended tx type starting with the activation of the `london` HF, see the following code snipped for an example on how to instantiate:\r\n\r\n```typescript\r\nimport { Chain, Common, Hardfork } from '@ethereumjs/common'\r\nimport { FeeMarketEIP1559Transaction } from '@ethereumjs/tx'\r\n\r\nconst common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London })\r\n\r\nconst txData = {\r\n  data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\r\n  gasLimit: '0x02625a00',\r\n  maxPriorityFeePerGas: '0x01',\r\n  maxFeePerGas: '0xff',\r\n  nonce: '0x00',\r\n  to: '0xcccccccccccccccccccccccccccccccccccccccc',\r\n  value: '0x0186a0',\r\n  v: '0x01',\r\n  r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',\r\n  s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',\r\n  chainId: '0x01',\r\n  accessList: [],\r\n  type: '0x02',\r\n}\r\n\r\nconst tx = FeeMarketEIP1559Transaction.fromTxData(txData, { common })\r\n```\r\n\r\n#### Access List Transactions (EIP-2930)\r\n\r\n- Class: `AccessListEIP2930Transaction`\r\n- Activation: `berlin`\r\n- Type: `1`\r\n\r\nThis transaction type has been introduced along the `berlin` HF. See the following code snipped for an example on how to instantiate:\r\n\r\n```typescript\r\nimport { Chain, Common, Hardfork } from '@ethereumjs/common'\r\nimport { AccessListEIP2930Transaction } from '@ethereumjs/tx'\r\n\r\nconst common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin })\r\n\r\nconst txData = {\r\n  data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\r\n  gasLimit: '0x02625a00',\r\n  gasPrice: '0x01',\r\n  nonce: '0x00',\r\n  to: '0xcccccccccccccccccccccccccccccccccccccccc',\r\n  value: '0x0186a0',\r\n  v: '0x01',\r\n  r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',\r\n  s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',\r\n  chainId: '0x01',\r\n  accessList: [\r\n    {\r\n      address: '0x0000000000000000000000000000000000000101',\r\n      storageKeys: [\r\n        '0x0000000000000000000000000000000000000000000000000000000000000000',\r\n        '0x00000000000000000000000000000000000000000000000000000000000060a7',\r\n      ],\r\n    },\r\n  ],\r\n  type: '0x01',\r\n}\r\n\r\nconst tx = AccessListEIP2930Transaction.fromTxData(txData, { common })\r\n```\r\n\r\nFor generating access lists from tx data based on a certain network state there is a `reportAccessList` option\r\non the `Vm.runTx()` method of the `@ethereumjs/vm` `TypeScript` VM implementation.\r\n\r\n### Legacy Transactions\r\n\r\n- Class: `Transaction`\r\n- Activation: `chainstart` (with modifications along the road, see HF section below)\r\n- Type: `0` (internal)\r\n\r\nLegacy transaction are still valid transaction within Ethereum `mainnet` but will likely be deprecated at some point.\r\nSee this [example script](./examples/transactions.ts) or the following code example on how to use.\r\n\r\n```typescript\r\nimport { Chain, Common, Hardfork } from '@ethereumjs/common'\r\nimport { Transaction } from '@ethereumjs/tx'\r\n\r\nconst txParams = {\r\n  nonce: '0x00',\r\n  gasPrice: '0x09184e72a000',\r\n  gasLimit: '0x2710',\r\n  to: '0x0000000000000000000000000000000000000000',\r\n  value: '0x00',\r\n  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',\r\n}\r\n\r\nconst common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Istanbul })\r\nconst tx = Transaction.fromTxData(txParams, { common })\r\n\r\nconst privateKey = Buffer.from(\r\n  'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109',\r\n  'hex'\r\n)\r\n\r\nconst signedTx = tx.sign(privateKey)\r\n\r\nconst serializedTx = signedTx.serialize()\r\n```\r\n\r\n### Transaction Factory\r\n\r\nIf you only know on runtime which tx type will be used within your code or if you want to keep your code transparent to tx types, this library comes with a `TransactionFactory` for your convenience which can be used as follows:\r\n\r\n```typescript\r\nimport { Chain, Common, Hardfork } from '@ethereumjs/common'\r\nimport { TransactionFactory } from '@ethereumjs/tx'\r\n\r\nconst common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.Berlin })\r\n\r\nconst txData = {} // Use data from the different tx type examples\r\nconst tx = TransactionFactory.fromTxData(txData, { common })\r\n\r\nif (tx.supports(Capability.EIP2930AccessLists)) {\r\n  // Do something which only makes sense for txs with support for access lists\r\n}\r\n```\r\n\r\nThe correct tx type class for instantiation will then be chosen on runtime based on the data provided as an input.\r\n\r\n`TransactionFactory` supports the following static constructor methods:\r\n\r\n- `public static fromTxData(txData: TxData | AccessListEIP2930TxData, txOptions: TxOptions = {}): TypedTransaction`\r\n- `public static fromSerializedData(data: Buffer, txOptions: TxOptions = {}): TypedTransaction`\r\n- `public static fromBlockBodyData(data: Buffer | Buffer[], txOptions: TxOptions = {})`\r\n\r\n### Sending a Transaction\r\n\r\n#### L2 Support\r\n\r\nThis library has been tested to work with various L2 networks (`v3.3.0`+). All predefined supported custom chains introduced with `Common` `v2.4.0` or higher are supported, the following is a simple example to send a tx to the xDai chain:\r\n\r\n```typescript\r\nimport { Transaction } from '@ethereumjs/tx'\r\nimport { Common } from '@ethereumjs/common'\r\n\r\nconst from = 'PUBLIC_KEY'\r\nconst PRIV_KEY = process.argv[2]\r\nconst to = 'DESTINATION_ETHEREUM_ADDRESS'\r\n\r\nconst common = Common.custom(CustomChain.xDaiChain)\r\n\r\nconst txData = {\r\n  from,\r\n  nonce: 0,\r\n  gasPrice: 1000000000,\r\n  gasLimit: 21000,\r\n  to,\r\n  value: 1,\r\n}\r\n\r\nconst tx = Transaction.fromTxData(txData, { common })\r\nconst signedTx = tx.sign(Buffer.from(PRIV_KEY, 'hex'))\r\n```\r\n\r\nThe following L2 networks have been tested to work with `@ethereumjs/tx`, see usage examples as well as some notes on pecularities in the issues linked below:\r\n\r\n|  L2 Network              |  Common name                          |  Issue                                                                  |\r\n| ------------------------ | ------------------------------------- | ----------------------------------------------------------------------- |\r\n| Arbitrum Rinkeby Testnet |  `CustomChain.ArbitrumRinkebyTestnet` |  [#1290](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1290) |\r\n| Polygon Mainnet          |  `CustomChain.PolygonMainnet`         |  [#1289](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1289) |\r\n| Polygon Mumbai Testnet   |  `CustomChain.PolygonMumbai`          |  [#1289](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1289) |\r\n| xDai Chain               |  `Common.xDaiChain`                   |  [#1323](https://github.com/ethereumjs/ethereumjs-monorepo/issues/1323) |\r\n| Optimistic Kovan         | `Common.OptimisticKovan`              | [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554)    |\r\n| Optimistic Ethereum      | `Common.OptimisticEthereum`           | [#1554](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1554)    |\r\n\r\nNote: For Optimistic Kovan and Optimistic Ethereum, the London hardfork has not been implemented so transactions submitted with a `baseFee` will revert.\r\nThe London hardfork is targeted to implement on Optimism in Q1.22.\r\n\r\nFor a non-predefined custom chain it is also possible to just provide a chain ID as well as other parameters to `Common`:\r\n\r\n```typescript\r\nconst common = Common.custom({ chainId: 1234 })\r\n```\r\n\r\n## Special Topics\r\n\r\n### Signing with a hardware or external wallet\r\n\r\nTo sign a tx with a hardware or external wallet use `tx.getMessageToSign(false)` to return an [EIP-155](https://eips.ethereum.org/EIPS/eip-155) compliant unsigned tx.\r\n\r\nA legacy transaction will return a Buffer list of the values, and a Typed Transaction ([EIP-2718](https://eips.ethereum.org/EIPS/eip-2718)) will return the serialized output.\r\n\r\nHere is an example of signing txs with `@ledgerhq/hw-app-eth` as of `v6.5.0`:\r\n\r\n```typescript\r\nimport { Transaction, FeeMarketEIP1559Transaction } from '@ethereumjs/tx'\r\nimport { Chain, Common } from '@ethereumjs/common'\r\nimport { bufArrToArr } from '@ethereumjs/util'\r\nimport { RLP } from '@ethereumjs/rlp'\r\nimport Eth from '@ledgerhq/hw-app-eth'\r\n\r\nconst eth = new Eth(transport)\r\nconst common = new Common({ chain: Chain.Rinkeby })\r\n\r\nlet txData: any = { value: 1 }\r\nlet tx: Transaction | FeeMarketEIP1559Transaction\r\nlet unsignedTx: Buffer[] | Buffer\r\nlet signedTx: typeof tx\r\nconst bip32Path = \"44'/60'/0'/0/0\"\r\n\r\nconst run = async () => {\r\n  // Signing a legacy tx\r\n  tx = Transaction.fromTxData(txData, { common })\r\n  unsignedTx = tx.getMessageToSign(false)\r\n  unsignedTx = Buffer.from(RLP.encode(bufArrToArr(unsignedTx))) // ledger signTransaction API expects it to be serialized\r\n  let { v, r, s } = await eth.signTransaction(bip32Path, unsignedTx)\r\n  txData = { ...txData, v, r, s }\r\n  signedTx = Transaction.fromTxData(txData, { common })\r\n  let from = signedTx.getSenderAddress().toString()\r\n  console.log(`signedTx: 0x${signedTx.serialize().toString('hex')}\\nfrom: ${from}`)\r\n\r\n  // Signing a 1559 tx\r\n  txData = { value: 1 }\r\n  tx = FeeMarketEIP1559Transaction.fromTxData(txData, { common })\r\n  unsignedTx = tx.getMessageToSign(false)\r\n  ;({ v, r, s } = await eth.signTransaction(bip32Path, unsignedTx)) // this syntax is: object destructuring - assignment without declaration\r\n  txData = { ...txData, v, r, s }\r\n  signedTx = FeeMarketEIP1559Transaction.fromTxData(txData, { common })\r\n  from = signedTx.getSenderAddress().toString()\r\n  console.log(`signedTx: ${signedTx.serialize().toString('hex')}\\nfrom: ${from}`)\r\n}\r\n\r\nrun()\r\n```\r\n\r\n### Fake Transaction\r\n\r\nCreating a fake transaction for use in e.g. `VM.runTx()` is simple, just overwrite `getSenderAddress()` with a custom [`Address`](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/util/docs/classes/Address.md) like so:\r\n\r\n```typescript\r\nimport { Address } from '@ethereumjs/util'\r\nimport { Transaction } from '@ethereumjs/tx'\r\n\r\n_getFakeTransaction(txParams: TxParams): Transaction {\r\n  const from = Address.fromString(txParams.from)\r\n  delete txParams.from\r\n\r\n  const opts = { common: this._common, freeze: false }\r\n  const tx = Transaction.fromTxData(txParams, opts)\r\n\r\n  // override getSenderAddress\r\n  tx.getSenderAddress = () => { return from }\r\n\r\n  return tx\r\n}\r\n```\r\n\r\n## API\r\n\r\n### Docs\r\n\r\nGenerated TypeDoc API [Documentation](./docs/README.md)\r\n\r\n### BigInt Support\r\n\r\nStarting with v4 the usage of [BN.js](https://github.com/indutny/bn.js/) for big numbers has been removed from the library and replaced with the usage of the native JS [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) data type (introduced in `ES2020`).\r\n\r\nPlease note that number-related API signatures have changed along with this version update and the minimal build target has been updated to `ES2020`.\r\n\r\n## EthereumJS\r\n\r\nSee our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.\r\n\r\n## License\r\n\r\n[MPL-2.0](<https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)>)\r\n\r\n[discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue\r\n[discord-link]: https://discord.gg/TNwARpR\r\n[tx-npm-badge]: https://img.shields.io/npm/v/@ethereumjs/tx.svg\r\n[tx-npm-link]: https://www.npmjs.com/package/@ethereumjs/tx\r\n[tx-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20tx?label=issues\r\n[tx-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A\"package%3A+tx\"\r\n[tx-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/Tx/badge.svg\r\n[tx-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22Tx%22\r\n[tx-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=tx\r\n[tx-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx\r\n","readmeFilename":"README.md"}