{"name":"@ethereumjs/tx","version":"10.0.0","keywords":["ethereum","transactions"],"author":{"name":"mjbecze","email":"mb@ethdev.com"},"license":"MPL-2.0","_id":"@ethereumjs/tx@10.0.0","maintainers":[{"name":"axic","email":"alex@rtfs.hu"},{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},{"name":"acolytec3","email":"metroman374@gmail.com"},{"name":"g11tech","email":"gajinder@g11.in"}],"contributors":[{"url":"https://github.com/axic","name":"Alex Beregszaszi","email":"alex@rtfs.hu"}],"homepage":"https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#readme","bugs":{"url":"https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+tx%22"},"dist":{"shasum":"100ee3cf4cb7342cabeb4f0ec41f4ccadf50df26","tarball":"http://registry-npm.ywwl.com/@ethereumjs/tx/download/@ethereumjs/tx-10.0.0.tgz","fileCount":268,"integrity":"sha512-DApm04kp2nbvaOuHy2Rkcz1ZeJkTVgW6oCuNnQf9bRtGc+LsvLrdULE3LoGtBItEoNEcgXLJqrV0foooWFX6jw==","signatures":[{"sig":"MEYCIQDfy8cPLMO/4U3fUL9/prwv33OjGvV5QZ+HtTkNHrPA5AIhANCwQhqGytnsX9ly2KKC/TvJH2NlaMAUQg3utMXLSdQg","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":874620,"size":129654,"noattachment":false,"key":"/@ethereumjs/tx/-/@ethereumjs/tx-10.0.0.tgz"},"main":"dist/cjs/index.js","type":"module","types":"./dist/cjs/index.d.ts","module":"dist/esm/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"default":"./dist/esm/index.js","typescript":"./src/index.ts"},"require":"./dist/cjs/index.js"}},"gitHead":"9e461f54312bf20c710b43ab73f7d3ad753f8765","scripts":{"sc":"npm run spellcheck","tsc":"../../config/cli/ts-compile.sh","lint":"npm run biome && eslint  --config ./eslint.config.mjs .","test":"npm run test:node && npm run test:browser","biome":"npx @biomejs/biome check","build":"../../config/cli/ts-build.sh","clean":"../../config/cli/clean-package.sh","coverage":"DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts","examples":"tsx ../../scripts/examples-runner.ts -- tx","lint:fix":"npm run biome:fix && eslint  --fix --config ./eslint.config.mjs .","biome:fix":"npx @biomejs/biome check --write","test:node":"npx vitest run -c ../../config/vitest.config.mts","docs:build":"typedoc --options typedoc.mjs","spellcheck":"npm run spellcheck:ts && npm run spellcheck:md","test:browser":"npx vitest run --config=./vitest.config.browser.mts","spellcheck:md":"npx cspell --gitignore -c ../../config/cspell-md.json \"**.md\" --cache --show-suggestions --show-context","spellcheck:ts":"npx cspell --gitignore -c ../../config/cspell-ts.json \"./**/*.ts\" --cache --show-suggestions --show-context","examples:build":"npx embedme README.md","prepublishOnly":"../../config/cli/prepublish.sh","coverage:istanbul":"DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.istanbul.mts"},"_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"repository":{"url":"git+https://github.com/ethereumjs/ethereumjs-monorepo.git","type":"git"},"_npmVersion":"11.2.0","description":"Implementation of the various Ethereum Transaction Types","directories":{},"sideEffects":false,"_nodeVersion":"23.10.0","dependencies":{"@ethereumjs/rlp":"^10.0.0","@ethereumjs/util":"^10.0.0","@ethereumjs/common":"^10.0.0","ethereum-cryptography":"^3.2.0"},"_hasShrinkwrap":false,"devDependencies":{"yargs":"^17.7.2","minimist":"^1.2.8","node-dir":"^0.1.17","@types/minimist":"^1.2.5","@types/node-dir":"^0.0.37","micro-eth-signer":"^0.14.0","@ethereumjs/testdata":"1.0.0","@paulmillr/trusted-setups":"^0.1.2"},"_npmOperationalInternal":{"tmp":"tmp/tx_10.0.0_1745916903118_0.6128109002687541","host":"s3://npm-registry-packages-npm-production"},"readme":"# @ethereumjs/tx `v10`\n\n[![NPM Package][tx-npm-badge]][tx-npm-link]\n[![GitHub Issues][tx-issues-badge]][tx-issues-link]\n[![Actions Status][tx-actions-badge]][tx-actions-link]\n[![Code Coverage][tx-coverage-badge]][tx-coverage-link]\n[![Discord][discord-badge]][discord-link]\n\n| Implements schema and functions for the different Ethereum transaction types |\n| ---------------------------------------------------------------------------- |\n\n- 🦄 All tx types up to **Osaka**\n- 🌴 Tree-shakeable API\n- 👷🏼 Controlled dependency set (1 external + `@Noble` crypto)\n- 🎼 Unified tx type API\n- 📲 New type for **EIP-7702** account abstraction\n- 🔮 `EIP-7594` PeerDAS Blob Transactions\n- 🛵 190KB bundle size (all tx types) (47KB gzipped)\n- 🏄🏾‍♂️ WASM-free default + Fully browser ready\n\nRunnable examples live in [`examples/`](./examples/).\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Transaction Types](#transaction-types)\n- [Transaction Factory](#transaction-factory)\n- [Signing and Deserialization](#signing-and-deserialization)\n- [Custom Chains](#custom-chains)\n- [EIP-7702 Set-Code Transactions](#eip-7702-set-code-transactions)\n- [KZG Setup](#kzg-setup)\n- [Sending a Transaction](#sending-a-transaction)\n- [Amsterdam Validation](#amsterdam-validation)\n- [Architecture](#architecture)\n- [Browser](#browser)\n- [Hardware Wallets](#hardware-wallets)\n- [API](#api)\n- [EthereumJS](#ethereumjs)\n- [License](#license)\n\n## Installation\n\n```shell\nnpm install @ethereumjs/tx\n```\n\n## Getting Started\n\nPrefer factory functions (`createLegacyTx`, `createTx`, …) over calling transaction class constructors directly. Every transaction needs a `Common` for chain ID, hardfork, and field validation.\n\n```ts\nimport { Common, Mainnet } from '@ethereumjs/common'\nimport { createFeeMarket1559Tx } from '@ethereumjs/tx'\n```\n\n| Hardfork | Tx types introduced |\n| --- | --- |\n| `chainstart` | Legacy (type 0) |\n| `spuriousDragon` | EIP-155 replay protection |\n| `berlin` | EIP-2930 access list (type 1) |\n| `london` | EIP-1559 fee market (type 2) |\n| `cancun` | EIP-4844 blob (type 3) |\n| `prague` | EIP-7702 set-code (type 4) |\n| `amsterdam` | EIP-2780 intrinsic split; EIP-7976 / EIP-7981 floor (experimental) |\n\nProperties are frozen by default (`freeze: false` to opt out).\n\n## Transaction Types\n\n### Gas Fee Market (EIP-1559, type 2)\n\nRecommended tx type from `london` onward.\n\n```ts\n// ./examples/eip1559Tx.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport type { FeeMarketEIP1559TxData } from '@ethereumjs/tx'\nimport { createFeeMarket1559Tx } from '@ethereumjs/tx'\nimport { bytesToHex } from '@ethereumjs/util'\n\nconst common = new Common({ chain: Mainnet, hardfork: Hardfork.Cancun })\n\nconst txData: FeeMarketEIP1559TxData = {\n  data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\n  gasLimit: '0x02625a00',\n  maxPriorityFeePerGas: '0x01',\n  maxFeePerGas: '0xff',\n  nonce: '0x00',\n  to: '0xcccccccccccccccccccccccccccccccccccccccc',\n  value: '0x0186a0',\n  v: '0x01',\n  r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',\n  s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',\n  chainId: '0x01',\n  accessList: [],\n  type: '0x02',\n}\n\nconst tx = createFeeMarket1559Tx(txData, { common })\nconsole.log(bytesToHex(tx.hash())) // 0x6f9ef69ccb1de1aea64e511efd6542541008ced321887937c95b03779358ec8a\n```\n\n### Access List (EIP-2930, type 1)\n\n```ts\n// ./examples/accessListTx.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport type { AccessList2930TxData } from '@ethereumjs/tx'\nimport { createAccessList2930Tx } from '@ethereumjs/tx'\nimport { bytesToHex } from '@ethereumjs/util'\n\nconst common = new Common({ chain: Mainnet, hardfork: Hardfork.Berlin })\n\nconst txData: AccessList2930TxData = {\n  data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\n  gasLimit: '0x02625a00',\n  gasPrice: '0x01',\n  nonce: '0x00',\n  to: '0xcccccccccccccccccccccccccccccccccccccccc',\n  value: '0x0186a0',\n  v: '0x01',\n  r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',\n  s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',\n  chainId: '0x01',\n  accessList: [\n    {\n      address: '0x0000000000000000000000000000000000000101',\n      storageKeys: [\n        '0x0000000000000000000000000000000000000000000000000000000000000000',\n        '0x00000000000000000000000000000000000000000000000000000000000060a7',\n      ],\n    },\n  ],\n  type: '0x01',\n}\n\nconst tx = createAccessList2930Tx(txData, { common })\nconsole.log(bytesToHex(tx.hash())) // 0x9150cdebad74e88b038e6c6b964d99af705f9c0883d7f0bbc0f3e072358f5b1d\n```\n\nFor generating access lists from network state, use `reportAccessList` on `VM.runTx()` in [@ethereumjs/vm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm).\n\n### Blob (EIP-4844 / EIP-7594, type 3)\n\nRequires KZG on `Common` — see [KZG Setup](#kzg-setup). Use `serializeNetworkWrapper()` for JSON-RPC submission (includes blobs); `serialize()` for block-body format.\n\n```ts\n// ./examples/blobTx.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport type { BlobEIP4844TxData } from '@ethereumjs/tx'\nimport { createBlob4844Tx } from '@ethereumjs/tx'\nimport { bytesToHex, getBlobs, randomBytes } from '@ethereumjs/util'\nimport { trustedSetup } from '@paulmillr/trusted-setups/fast-peerdas.js'\nimport { KZG as microEthKZG } from 'micro-eth-signer/kzg.js'\n\nconst main = async () => {\n  const kzg = new microEthKZG(trustedSetup)\n  // EIP-4844 only\n  const common4844 = new Common({\n    chain: Mainnet,\n    hardfork: Hardfork.Cancun,\n    customCrypto: { kzg },\n  })\n\n  // EIP-4844 and EIP-7594\n  const common4844and7594 = new Common({\n    chain: Mainnet,\n    hardfork: Hardfork.Osaka,\n    customCrypto: { kzg },\n  })\n  const setups = [\n    {\n      title: 'Blob transaction (EIP-4844 only)',\n      common: common4844,\n      proofAmountComment: 'one proof per blob',\n    },\n    {\n      title: 'Blob transaction (EIP-4844 + EIP-7594)',\n      common: common4844and7594,\n      proofAmountComment: '128 cells per blob + one proof per cell -> NUM_BLOBS * 128 proofs',\n    },\n  ]\n\n  for (const setup of setups) {\n    console.log(`\\n${setup.title}:`)\n    console.log('---------------------------------------')\n\n    const blobsData = ['blob 1', 'blob 2', 'blob 3']\n    console.log(`Blobs (Data) : \"${blobsData.join('\", \"')}\"`)\n    // Final format, filled with a lot of 0s, added marker\n    const blobs = getBlobs(blobsData)\n\n    console.log('Generating tx...')\n\n    const txData: BlobEIP4844TxData = {\n      data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',\n      gasLimit: 16_000_000n,\n      maxPriorityFeePerGas: '0x01',\n      maxFeePerGas: '0xff',\n      maxFeePerBlobGas: '0xfff',\n      nonce: '0x00',\n      to: '0xcccccccccccccccccccccccccccccccccccccccc',\n      value: '0x0186a0',\n      v: '0x01',\n      r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',\n      s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',\n      chainId: '0x01',\n      accessList: [],\n      type: '0x05',\n      blobs,\n    }\n\n    const tx = createBlob4844Tx(txData, { common: setup.common })\n\n    console.log(`Tx hash               : ${bytesToHex(tx.hash())}`)\n    console.log(`Num blobs             : ${tx.numBlobs()}`)\n    console.log(`Blob versioned hashes : ${tx.blobVersionedHashes.join(', ')}`)\n    console.log(`KZG commitments       : ${tx.kzgCommitments!.join(', ')}`)\n    console.log(`First KZG (cell) proof: ${tx.kzgProofs![0]}`)\n    console.log(`Num KZG (cell) proofs : ${tx.kzgProofs!.length} (${setup.proofAmountComment})`)\n  }\n\n  // To send a transaction via RPC, you can something like this:\n  // const rawTx = tx.sign(privateKeyBytes).serializeNetworkWrapper()\n  // myRPCClient.request('eth_sendRawTransaction', [rawTx]) // submits a transaction via RPC\n  //\n  // Also see ./sendRawSepoliaTx.ts example\n}\n\nvoid main()\n```\n\n### EOA Code (EIP-7702, type 4)\n\nPrague+ txs with an authorization list. See [EIP-7702 Set-Code Transactions](#eip-7702-set-code-transactions) for a full sign-and-delegate workflow.\n\n```ts\n// ./examples/eoaCode7702Tx.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport { createEOACode7702Tx } from '@ethereumjs/tx'\nimport { type PrefixedHexString, createAddressFromPrivateKey, randomBytes } from '@ethereumjs/util'\n\nconst ones32 = `0x${'01'.repeat(32)}` as PrefixedHexString\n\nconst common = new Common({ chain: Mainnet, hardfork: Hardfork.Cancun, eips: [7702] })\nconst tx = createEOACode7702Tx(\n  {\n    authorizationList: [\n      {\n        chainId: '0x2',\n        address: `0x${'20'.repeat(20)}`,\n        nonce: '0x1',\n        yParity: '0x1',\n        r: ones32,\n        s: ones32,\n      },\n    ],\n    to: createAddressFromPrivateKey(randomBytes(32)),\n  },\n  { common },\n)\n\nconsole.log(\n  `EIP-7702 EOA code tx created with ${tx.authorizationList.length} authorization list item(s).`,\n)\n```\n\n### Legacy (type 0)\n\n```ts\n// ./examples/legacyTx.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport type { LegacyTxData } from '@ethereumjs/tx'\nimport { createLegacyTx } from '@ethereumjs/tx'\nimport { bytesToHex, hexToBytes } from '@ethereumjs/util'\n\nconst txData: LegacyTxData = {\n  nonce: '0x0',\n  gasPrice: '0x09184e72a000',\n  gasLimit: '0x2710',\n  to: '0x0000000000000000000000000000000000000000',\n  value: '0x00',\n  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',\n}\n\nconst common = new Common({ chain: Mainnet, hardfork: Hardfork.Istanbul })\nconst tx = createLegacyTx(txData, { common })\n\nconst privateKey = hexToBytes('0xe331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109')\n\nconst signedTx = tx.sign(privateKey)\n\nconst _serializedTx = signedTx.serialize()\nconsole.log(bytesToHex(signedTx.hash())) // 0x894b72d87f8333fccd29d1b3aca39af69d97a6bc281e7e7a3a60640690a3cd2b\n```\n\n## Transaction Factory\n\nWhen the tx type is only known at runtime, use `createTx()` — it dispatches on the `type` field or RLP prefix:\n\n```ts\n// ./examples/txFactory.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport { Capability, createTx } from '@ethereumjs/tx'\n\nimport type { EIP1559CompatibleTx } from '@ethereumjs/tx'\n\nconst common = new Common({ chain: Mainnet, hardfork: Hardfork.London })\n\nconst txData = { type: 2, maxFeePerGas: BigInt(20) } // Creates an EIP-1559 compatible transaction\nconst tx = createTx(txData, { common })\n\nif (tx.supports(Capability.EIP1559FeeMarket)) {\n  console.log(\n    `The max fee per gas for this transaction is ${(tx as EIP1559CompatibleTx).maxFeePerGas}`,\n  )\n}\n```\n\nFactory methods: `createTx`, `createTxFromRLP`, `createTxFromBlockBodyData`, `createTxFromRPC`, `createTxFromJSONRPCProvider`.\n\n## Signing and Deserialization\n\n### Sign, serialize, and verify\n\n```ts\n// ./examples/transactions.ts\n\nimport { createLegacyTx, createLegacyTxFromBytesArray } from '@ethereumjs/tx'\nimport { bytesToHex, hexToBytes, randomBytes } from '@ethereumjs/util'\n\n// Create and sign a contract-creation tx\nconst tx = createLegacyTx({\n  nonce: 0,\n  gasPrice: 100,\n  gasLimit: 1_000_000_000,\n  value: 0,\n  data: '0x7f4e616d65526567000000000000000000000000000000000000000000000000003057307f4e616d6552656700000000000000000000000000000000000000000000000000573360455760415160566000396000f20036602259604556330e0f600f5933ff33560f601e5960003356576000335700604158600035560f602b590033560f60365960003356573360003557600035335700',\n})\n\nconst signedTx = tx.sign(randomBytes(32))\nconsole.log(`Upfront cost: ${signedTx.getUpfrontCost()} wei`)\nconsole.log(`Serialized: ${bytesToHex(signedTx.serialize())}`)\n\n// Parse a signed legacy tx from its values array\nconst rawTx = [\n  '0x',\n  '0x09184e72a000',\n  '0x2710',\n  '0x0000000000000000000000000000000000000000',\n  '0x',\n  '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',\n  '0x1c',\n  '0x5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab',\n  '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13',\n].map(hexToBytes)\n\nconst parsed = createLegacyTxFromBytesArray(rawTx)\nconsole.log(`Sender: ${parsed.getSenderAddress().toString()}`)\nconsole.log(`Signature valid: ${parsed.verifySignature()}`)\n```\n\n### Deserialize from RLP\n\n```ts\n// ./examples/txFromRLP.ts\n\nimport { Common, Mainnet } from '@ethereumjs/common'\nimport { createFeeMarket1559Tx, createTxFromRLP } from '@ethereumjs/tx'\nimport { bytesToHex, hexToBytes } from '@ethereumjs/util'\n\nconst common = new Common({ chain: Mainnet })\nconst privateKey = hexToBytes('0xe331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109')\n\nconst tx = createFeeMarket1559Tx(\n  {\n    type: 2,\n    nonce: 0n,\n    gasLimit: 21_000n,\n    maxFeePerGas: 20n,\n    maxPriorityFeePerGas: 1n,\n    to: '0xcccccccccccccccccccccccccccccccccccccccc',\n  },\n  { common },\n).sign(privateKey)\n\nconst roundTrip = createTxFromRLP(tx.serialize(), { common })\n\nconsole.log(`Type preserved: ${roundTrip.type === tx.type}`)\nconsole.log(`Hash match: ${bytesToHex(roundTrip.hash()) === bytesToHex(tx.hash())}`)\n```\n\n### Deserialize with custom chain ID\n\nWhen parsing txs from a non-mainnet chain, pass a matching `Common`:\n\n```ts\n// ./examples/customChainIdTx.ts\n\nimport { Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common'\nimport { createLegacyTxFromRLP } from '@ethereumjs/tx'\nimport { hexToBytes, toBytes } from '@ethereumjs/util'\n\nconst txData = hexToBytes(\n  '0xf9010b82930284d09dc30083419ce0942d18de92e0f9aee1a29770c3b15c6cf8ac5498e580b8a42f43f4fb0000000000000000000000000000000000000000000000000000016b78998da900000000000000000000000000000000000000000000000000000000000cb1b70000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000001363e4f00000000000000000000000000000000000000000000000000000000000186a029a0fac36e66d329af0e831b2e61179b3ec8d7c7a8a2179e303cfed3364aff2bc3e4a07cb73d56e561ccbd838818dd3dea5fa0b5158577ffc61c0e6ec1f0ed55716891',\n)\n\nconst common = createCustomCommon({ chainId: 3 }, Mainnet)\ncommon.setHardfork(Hardfork.Prague)\nconst tx = createLegacyTxFromRLP(txData, { common })\n\nif (\n  tx.isValid() &&\n  tx.getSenderAddress().toString() === '0x9dfd2d2b2ed960923f7bf2e8883d73f213f3b24b'\n) {\n  console.log('Correctly created the tx')\n} else {\n  console.error('Invalid tx')\n}\n```\n\n## Custom Chains\n\nUse `createCustomCommon()` from `@ethereumjs/common` to override `chainId` (and optionally name) while keeping mainnet parameters:\n\n```ts\n// ./examples/customChainTx.ts\n\nimport { Hardfork, Mainnet, createCustomCommon } from '@ethereumjs/common'\nimport { createLegacyTx } from '@ethereumjs/tx'\nimport { createAddressFromPrivateKey, hexToBytes } from '@ethereumjs/util'\n\n// In this example we create a transaction for a custom network.\n\n// This custom network has the same params as mainnet,\n// except for name, chainId, so we use the `Common.custom` method.\nconst customCommon = createCustomCommon(\n  {\n    name: 'my-network',\n    chainId: 2134,\n  },\n  Mainnet,\n  {\n    hardfork: Hardfork.Prague,\n  },\n)\n\n// We pass our custom Common object whenever we create a transaction\nconst opts = { common: customCommon }\nconst tx = createLegacyTx(\n  {\n    nonce: 0,\n    gasPrice: 100,\n    gasLimit: 1000000000,\n    value: 100000,\n  },\n  opts,\n)\n\n// Once we created the transaction using the custom Common object, we can use it as a normal tx.\n\n// Here we sign it and validate its signature\nconst privateKey = hexToBytes('0xe331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109')\n\nconst signedTx = tx.sign(privateKey)\nconst address = createAddressFromPrivateKey(privateKey)\n\nif (signedTx.isValid() && signedTx.getSenderAddress().equals(address)) {\n  console.log('Valid signature')\n} else {\n  console.log('Invalid signature')\n}\n\nconsole.log(\"The transaction's chain id is: \", signedTx.common.chainId().toString())\n```\n\nL2 example (xDai / Gnosis chain ID 100):\n\n```ts\n// ./examples/l2Tx.ts\n\nimport { Mainnet, createCustomCommon } from '@ethereumjs/common'\nimport { createLegacyTx } from '@ethereumjs/tx'\nimport { bytesToHex, createAddressFromString, hexToBytes } from '@ethereumjs/util'\n\nconst pk = hexToBytes('0x076247989df60a82f6e86e58104368676096f84e60972282ee00d4673a2bc9b9')\n// xDai chain ID\nconst common = createCustomCommon({ chainId: 100 }, Mainnet)\nconst to = createAddressFromString('0x256e8f0ba532ad83a0debde7501669511a41a1f3')\n\nconst txData = {\n  nonce: 0,\n  gasPrice: 1000000000,\n  gasLimit: 21000,\n  to,\n  value: 1,\n}\n\nconst tx = createLegacyTx(txData, { common })\nconst signedTx = tx.sign(pk)\nconsole.log(bytesToHex(signedTx.hash())) // 0xbf98f6f8700812ed6f2314275070256e11945fa48afd80fb301265f6a41a2dc2\n```\n\n## EIP-7702 Set-Code Transactions\n\nFull workflow: sign authorization items with `@ethereumjs/util`, attach to a type-4 tx, sign and serialize. **Do not use real keys with funds.**\n\n```ts\n// ./examples/setEOATx.ts\n\n/**\n * This example shows how to initialize an EIP-7702 (Set EOA account code) transaction\n * WARNING: do NOT try this or sign this with any keys which have any value on any network\n * This is for educational purposes only.\n */\n\n// This example will show how to self-delegate a fresh EOA account to the address `0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`\n// In the same transaction, it will also delegate another account to address `0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb`\n// It will self-delegate. Note that in a 7702-tx, you are free to include any authorization item.\n// If the authorization item is valid (it has the correct nonce, and matches the chainId (or the chainId is 0))\n// then it will delegate the code of the account **who signed that authorization item** to the address in that authority item\nimport { createEOACode7702Tx } from '@ethereumjs/tx'\nimport type { EOACode7702AuthorizationListItemUnsigned } from '@ethereumjs/util'\nimport {\n  Address,\n  eoaCode7702AuthorizationListBytesItemToJSON,\n  eoaCode7702SignAuthorization,\n  privateToAddress,\n} from '@ethereumjs/util'\n\nconst privateKey = new Uint8Array(32).fill(0x20)\nconst privateKeyOther = new Uint8Array(32).fill(0x99)\n\nconst myAddress = new Address(privateToAddress(privateKey))\n\nconst unsignedAuthorizationListItemSelf: EOACode7702AuthorizationListItemUnsigned = {\n  chainId: '0x1337', // This delegation will only work on the chain with chainId 0x1337\n  address: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',\n  nonce: '0x01', // Since we are self-delegating we need account for the nonce being bumped of the account\n}\nconst signedSelf = eoaCode7702SignAuthorization(unsignedAuthorizationListItemSelf, privateKey)\n// To convert the bytes array to a human-readable form, use `eoaCode7702AuthorizationListBytesItemToJSON`\nconsole.log(eoaCode7702AuthorizationListBytesItemToJSON(signedSelf))\n\nconst unsignedAuthorizationListItemOther: EOACode7702AuthorizationListItemUnsigned = {\n  chainId: '0x', // The chainId 0 is special: this authorization will work on any chain which supports EIP-7702\n  address: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',\n  nonce: '0x',\n}\nconst signedOther = eoaCode7702SignAuthorization(\n  unsignedAuthorizationListItemOther,\n  privateKeyOther,\n)\n\nconst authorizationList = [signedSelf, signedOther]\n\nconst unsignedTx = createEOACode7702Tx({\n  authorizationList,\n  to: myAddress, // Call into self, so call into own address into `0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`\n})\n\nconst signed = unsignedTx.sign(privateKey)\n\nconsole.log(signed.toJSON())\n```\n\n## KZG Setup\n\nBlob transactions and KZG precompiles need a KZG implementation on `Common.customCrypto.kzg`:\n\n```ts\n// ./examples/initKZG.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport { trustedSetup } from '@paulmillr/trusted-setups/fast-peerdas.js'\nimport { KZG as microEthKZG } from 'micro-eth-signer/kzg.js'\n\nconst main = async () => {\n  const kzg = new microEthKZG(trustedSetup)\n  // Instantiate `common`\n  const common = new Common({\n    chain: Mainnet,\n    hardfork: Hardfork.Cancun,\n    customCrypto: { kzg },\n  })\n\n  console.log(`KZG configured: ${Boolean(common.customCrypto.kzg)}`)\n}\n\nvoid main()\n```\n\nInstall [micro-eth-signer](https://github.com/paulmillr/micro-eth-signer) and [@paulmillr/trusted-setups](https://github.com/paulmillr/trusted-setups) as dependencies. The trusted setup is large and intentionally not bundled.\n\n## Sending a Transaction\n\nSee [sendRawSepoliaTx.ts](./examples/sendRawSepoliaTx.ts) for submitting a signed blob tx via JSON-RPC. For blob txs use `serializeNetworkWrapper()`, not `serialize()`.\n\n## Amsterdam Validation\n\nSee the [canonical Amsterdam overview](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm#amsterdam-hardfork-experimental) in `@ethereumjs/vm`.\n\nIntrinsic gas and the calldata floor are **two meters**. Wallets take `max` of both (`getMinimumGasLimit()`). They share EIP-2780's recipient/value extras as a common base; they are not two names for the same formula.\n\n**Intrinsic ([EIP-2780](https://eips.ethereum.org/EIPS/eip-2780))** splits the old flat 21_000. A value transfer to another account is still 21_000:\n\n| Part | Gas |\n| --- | --- |\n| `TX_BASE` (`txGas`) | 12_000 |\n| Recipient access | 3_000 |\n| Value (+ transfer log) | 6_000 |\n\nSelf-transfers skip the extras (12_000). `getIntrinsicGas()` still adds calldata execution cost, create, access-list, and 7702 auth on top.\n\n**Calldata floor ([EIP-7623](https://eips.ethereum.org/EIPS/eip-7623), raised by [EIP-7976](https://eips.ethereum.org/EIPS/eip-7976))** is `floor_base + totalCostFloorPerToken × tokens`. Prague introduced the floor so data-heavy txs cannot underpay. Amsterdam's EIP-7976 counts **4 tokens per calldata byte** (zero and non-zero alike) and sets `totalCostFloorPerToken` to 16 → 64 gas per byte. [EIP-7981](https://eips.ethereum.org/EIPS/eip-7981) adds access-list bytes to the same token count. EIP-2780 extras are the floor **base** (`TX_BASE` + recipient/value), not a second floor.\n\n**Minimum `gasLimit`:** `getMinimumGasLimit()` = `max(intrinsic, floor)`. Empty transfers still pass 21_000 (intrinsic ≥ floor). Calldata often cannot. First-touch state gas ([EIP-8037](https://eips.ethereum.org/EIPS/eip-8037)) is **not** in this bound — use `estimateTxGasDimensions()` on `@ethereumjs/vm`.\n\n```ts\n// ./examples/calldataFloorGas.ts\n\nimport { Common, Hardfork, Mainnet } from '@ethereumjs/common'\nimport {\n  countCalldataFloorTokens,\n  createLegacyTx,\n  getCalldataFloorGas,\n  getEip2780FloorBaseGas,\n  getEip2780RecipientRegularGas,\n} from '@ethereumjs/tx'\nimport { createAddressFromPrivateKey, createZeroAddress, hexToBytes } from '@ethereumjs/util'\n\nimport type { LegacyTxInterface } from '@ethereumjs/tx'\n\nconst main = () => {\n  const common = new Common({ chain: Mainnet, hardfork: Hardfork.Amsterdam })\n  const senderKey = hexToBytes(`0x${'20'.repeat(32)}`)\n  const sender = createAddressFromPrivateKey(senderKey)\n  const other = createZeroAddress()\n\n  const report = (label: string, tx: LegacyTxInterface) => {\n    console.log(label)\n    console.log(`  TX_BASE:      ${tx.common.param('txGas')}`)\n    console.log(`  2780 extras:  ${getEip2780RecipientRegularGas(tx)}`)\n    console.log(`  floor base:   ${getEip2780FloorBaseGas(tx)}`)\n    console.log(`  floor tokens: ${countCalldataFloorTokens(tx)}`)\n    console.log(`  intrinsic:    ${tx.getIntrinsicGas()}`)\n    console.log(`  floor:        ${getCalldataFloorGas(tx)}`)\n    console.log(`  minimum:      ${tx.getMinimumGasLimit()}`)\n    console.log(`  gasLimit:     ${tx.gasLimit} valid=${tx.isValid()}`)\n  }\n\n  report(\n    'Value transfer to another account (still 21_000)',\n    createLegacyTx(\n      { to: other, value: 1n, gasLimit: 21_000n, gasPrice: 10n },\n      { common },\n    ).sign(senderKey),\n  )\n\n  report(\n    'Self-transfer (2780 extras skipped)',\n    createLegacyTx(\n      { to: sender, value: 1n, gasLimit: 21_000n, gasPrice: 10n },\n      { common },\n    ).sign(senderKey),\n  )\n\n  report(\n    '100 calldata bytes (7976 floor exceeds 21_000)',\n    createLegacyTx(\n      { to: other, data: new Uint8Array(100).fill(1), gasLimit: 21_000n, gasPrice: 10n },\n      { common },\n    ).sign(senderKey),\n  )\n}\n\nvoid main()\n```\n\nFirst-touch state gas is still a VM concern: [`@ethereumjs/vm` Amsterdam gas dimensions](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/vm#amsterdam-gas-dimensions).\n\n## Architecture\n\nOne directory per typed transaction (`legacy/`, `2930/`, `1559/`, `4844/`, `7702/`) with shared behavior in `capabilities/`. `transactionFactory.ts` dispatches `createTx*` calls. Every tx is built with a `Common` instance.\n\n## Browser\n\nWe provide hybrid ESM/CJS builds for all our libraries. With the v10 breaking release round from Spring 2025, all libraries are \"pure-JS\" by default and we have eliminated all hard-wired WASM code. Additionally we have substantially lowered the bundle sizes, reduced the number of dependencies, and cut out all usages of Node.js-specific primitives (like the Node.js event emitter).\n\nIt is easily possible to run a browser build of one of the EthereumJS libraries within a modern browser using the provided ESM build. For a setup example see [./examples/browser.html](./examples/browser.html).\n\n## Hardware Wallets\n\nUse `tx.getMessageToSign()` for unsigned payloads. Legacy txs return an RLP values list; typed txs return serialized bytes. See [ledgerSigner.mts](./examples/ledgerSigner.mts) for `@ledgerhq/hw-app-eth` integration.\n\n## API\n\nGenerated TypeDoc [documentation](./docs/README.md).\n\nWASM crypto backends can be plugged in via `Common.customCrypto` — see [@ethereumjs/common](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common#custom-cryptography-wasm--kzg).\n\n## EthereumJS\n\nThe `EthereumJS` GitHub organization and its repositories are managed by members of the former Ethereum Foundation JavaScript team and the broader Ethereum community. If you want to join for work or carry out improvements on the libraries see the [developer docs](../../DEVELOPER.md) for an overview of current standards and tools and review our [code of conduct](../../CODE_OF_CONDUCT.md).\n\n## License\n\n[MPL-2.0](<https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)>)\n\n[discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue\n[discord-link]: https://discord.gg/TNwARpR\n[tx-npm-badge]: https://img.shields.io/npm/v/@ethereumjs/tx.svg\n[tx-npm-link]: https://www.npmjs.com/package/@ethereumjs/tx\n[tx-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20tx?label=issues\n[tx-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A\"package%3A+tx\"\n[tx-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/Tx/badge.svg\n[tx-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22Tx%22\n[tx-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=tx\n[tx-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx\n","publish_time":1745916903309,"_cnpm_publish_time":1745916903309,"dist-tags":{"alpha":"6.0.0-alpha.1","beta":"4.0.0-beta.3","latest":"10.1.3","nightly":"10.1.1-nightly.2","rc":"10.0.0-rc.1"}}