-
Notifications
You must be signed in to change notification settings - Fork 729
/
eip4844Transaction.ts
659 lines (593 loc) · 21.9 KB
/
eip4844Transaction.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
import { RLP } from '@ethereumjs/rlp'
import {
BIGINT_0,
BIGINT_27,
MAX_INTEGER,
bigIntToHex,
bigIntToUnpaddedBytes,
blobsToCommitments,
blobsToProofs,
bytesToBigInt,
bytesToHex,
commitmentsToVersionedHashes,
computeVersionedHash,
equalsBytes,
getBlobs,
toBytes,
validateNoLeadingZeroes,
} from '@ethereumjs/util'
import { BaseTransaction } from './baseTransaction.js'
import * as EIP1559 from './capabilities/eip1559.js'
import * as EIP2718 from './capabilities/eip2718.js'
import * as EIP2930 from './capabilities/eip2930.js'
import * as Legacy from './capabilities/legacy.js'
import { LIMIT_BLOBS_PER_TX } from './constants.js'
import { TransactionType } from './types.js'
import { AccessLists, txTypeBytes } from './util.js'
import type {
AccessList,
AccessListBytes,
TxData as AllTypesTxData,
TxValuesArray as AllTypesTxValuesArray,
BlobEIP4844NetworkValuesArray,
JsonBlobTxNetworkWrapper,
JsonTx,
TxOptions,
} from './types.js'
import type { Common } from '@ethereumjs/common'
import type { Kzg } from '@ethereumjs/util'
type TxData = AllTypesTxData[TransactionType.BlobEIP4844]
type TxValuesArray = AllTypesTxValuesArray[TransactionType.BlobEIP4844]
const validateBlobTransactionNetworkWrapper = (
blobVersionedHashes: Uint8Array[],
blobs: Uint8Array[],
commitments: Uint8Array[],
kzgProofs: Uint8Array[],
version: number,
kzg: Kzg
) => {
if (!(blobVersionedHashes.length === blobs.length && blobs.length === commitments.length)) {
throw new Error('Number of blobVersionedHashes, blobs, and commitments not all equal')
}
if (blobVersionedHashes.length === 0) {
throw new Error('Invalid transaction with empty blobs')
}
let isValid
try {
isValid = kzg.verifyBlobKzgProofBatch(blobs, commitments, kzgProofs)
} catch (error) {
throw new Error(`KZG verification of blobs fail with error=${error}`)
}
if (!isValid) {
throw new Error('KZG proof cannot be verified from blobs/commitments')
}
for (let x = 0; x < blobVersionedHashes.length; x++) {
const computedVersionedHash = computeVersionedHash(commitments[x], version)
if (!equalsBytes(computedVersionedHash, blobVersionedHashes[x])) {
throw new Error(`commitment for blob at index ${x} does not match versionedHash`)
}
}
}
/**
* Typed transaction with a new gas fee market mechanism for transactions that include "blobs" of data
*
* - TransactionType: 3
* - EIP: [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
*/
export class BlobEIP4844Transaction extends BaseTransaction<TransactionType.BlobEIP4844> {
public readonly chainId: bigint
public readonly accessList: AccessListBytes
public readonly AccessListJSON: AccessList
public readonly maxPriorityFeePerGas: bigint
public readonly maxFeePerGas: bigint
public readonly maxFeePerBlobGas: bigint
public readonly common: Common
public blobVersionedHashes: Uint8Array[]
blobs?: Uint8Array[] // This property should only be populated when the transaction is in the "Network Wrapper" format
kzgCommitments?: Uint8Array[] // This property should only be populated when the transaction is in the "Network Wrapper" format
kzgProofs?: Uint8Array[] // This property should only be populated when the transaction is in the "Network Wrapper" format
/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static constructors or factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData: TxData, opts: TxOptions = {}) {
super({ ...txData, type: TransactionType.BlobEIP4844 }, opts)
const { chainId, accessList, maxFeePerGas, maxPriorityFeePerGas, maxFeePerBlobGas } = txData
this.common = this._getCommon(opts.common, chainId)
this.chainId = this.common.chainId()
if (!this.common.isActivatedEIP(1559)) {
throw new Error('EIP-1559 not enabled on Common')
}
if (!this.common.isActivatedEIP(4844)) {
throw new Error('EIP-4844 not enabled on Common')
}
this.activeCapabilities = this.activeCapabilities.concat([1559, 2718, 2930])
// Populate the access list fields
const accessListData = AccessLists.getAccessListData(accessList ?? [])
this.accessList = accessListData.accessList
this.AccessListJSON = accessListData.AccessListJSON
// Verify the access list format.
AccessLists.verifyAccessList(this.accessList)
this.maxFeePerGas = bytesToBigInt(toBytes(maxFeePerGas))
this.maxPriorityFeePerGas = bytesToBigInt(toBytes(maxPriorityFeePerGas))
this._validateCannotExceedMaxInteger({
maxFeePerGas: this.maxFeePerGas,
maxPriorityFeePerGas: this.maxPriorityFeePerGas,
})
BaseTransaction._validateNotArray(txData)
if (this.gasLimit * this.maxFeePerGas > MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)')
throw new Error(msg)
}
if (this.maxFeePerGas < this.maxPriorityFeePerGas) {
const msg = this._errorMsg(
'maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)'
)
throw new Error(msg)
}
this.maxFeePerBlobGas = bytesToBigInt(
toBytes((maxFeePerBlobGas ?? '') === '' ? '0x' : maxFeePerBlobGas)
)
this.blobVersionedHashes = (txData.blobVersionedHashes ?? []).map((vh) => toBytes(vh))
EIP2718.validateYParity(this)
Legacy.validateHighS(this)
for (const hash of this.blobVersionedHashes) {
if (hash.length !== 32) {
const msg = this._errorMsg('versioned hash is invalid length')
throw new Error(msg)
}
if (BigInt(hash[0]) !== this.common.param('sharding', 'blobCommitmentVersionKzg')) {
const msg = this._errorMsg('versioned hash does not start with KZG commitment version')
throw new Error(msg)
}
}
if (this.blobVersionedHashes.length > LIMIT_BLOBS_PER_TX) {
const msg = this._errorMsg(`tx can contain at most ${LIMIT_BLOBS_PER_TX} blobs`)
throw new Error(msg)
} else if (this.blobVersionedHashes.length === 0) {
const msg = this._errorMsg(`tx should contain at least one blob`)
throw new Error(msg)
}
if (this.to === undefined) {
const msg = this._errorMsg(
`tx should have a "to" field and cannot be used to create contracts`
)
throw new Error(msg)
}
this.blobs = txData.blobs?.map((blob) => toBytes(blob))
this.kzgCommitments = txData.kzgCommitments?.map((commitment) => toBytes(commitment))
this.kzgProofs = txData.kzgProofs?.map((proof) => toBytes(proof))
const freeze = opts?.freeze ?? true
if (freeze) {
Object.freeze(this)
}
}
public static fromTxData(txData: TxData, opts?: TxOptions) {
if (opts?.common?.customCrypto?.kzg === undefined) {
throw new Error(
'A common object with customCrypto.kzg initialized required to instantiate a 4844 blob tx'
)
}
const kzg = opts!.common!.customCrypto!.kzg!
if (txData.blobsData !== undefined) {
if (txData.blobs !== undefined) {
throw new Error('cannot have both raw blobs data and encoded blobs in constructor')
}
if (txData.kzgCommitments !== undefined) {
throw new Error('cannot have both raw blobs data and KZG commitments in constructor')
}
if (txData.blobVersionedHashes !== undefined) {
throw new Error('cannot have both raw blobs data and versioned hashes in constructor')
}
if (txData.kzgProofs !== undefined) {
throw new Error('cannot have both raw blobs data and KZG proofs in constructor')
}
txData.blobs = getBlobs(txData.blobsData.reduce((acc, cur) => acc + cur))
txData.kzgCommitments = blobsToCommitments(kzg, txData.blobs as Uint8Array[])
txData.blobVersionedHashes = commitmentsToVersionedHashes(
txData.kzgCommitments as Uint8Array[]
)
txData.kzgProofs = blobsToProofs(
kzg,
txData.blobs as Uint8Array[],
txData.kzgCommitments as Uint8Array[]
)
}
return new BlobEIP4844Transaction(txData, opts)
}
/**
* Returns the minimum of calculated priority fee (from maxFeePerGas and baseFee) and maxPriorityFeePerGas
* @param baseFee Base fee retrieved from block
*/
getEffectivePriorityFee(baseFee: bigint): bigint {
return EIP1559.getEffectivePriorityFee(this, baseFee)
}
/**
* Creates the minimal representation of a blob transaction from the network wrapper version.
* The minimal representation is used when adding transactions to an execution payload/block
* @param txData a {@link BlobEIP4844Transaction} containing optional blobs/kzg commitments
* @param opts - dictionary of {@link TxOptions}
* @returns the "minimal" representation of a BlobEIP4844Transaction (i.e. transaction object minus blobs and kzg commitments)
*/
public static minimalFromNetworkWrapper(
txData: BlobEIP4844Transaction,
opts?: TxOptions
): BlobEIP4844Transaction {
if (opts?.common?.customCrypto?.kzg === undefined) {
throw new Error(
'A common object with customCrypto.kzg initialized required to instantiate a 4844 blob tx'
)
}
const tx = BlobEIP4844Transaction.fromTxData(
{
...txData,
...{ blobs: undefined, kzgCommitments: undefined, kzgProofs: undefined },
},
opts
)
return tx
}
/**
* Instantiate a transaction from the serialized tx.
*
* Format: `0x03 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data,
* access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, s])`
*/
public static fromSerializedTx(serialized: Uint8Array, opts: TxOptions = {}) {
if (opts.common?.customCrypto?.kzg === undefined) {
throw new Error(
'A common object with customCrypto.kzg initialized required to instantiate a 4844 blob tx'
)
}
if (
equalsBytes(serialized.subarray(0, 1), txTypeBytes(TransactionType.BlobEIP4844)) === false
) {
throw new Error(
`Invalid serialized tx input: not an EIP-4844 transaction (wrong tx type, expected: ${
TransactionType.BlobEIP4844
}, received: ${bytesToHex(serialized.subarray(0, 1))}`
)
}
const values = RLP.decode(serialized.subarray(1))
if (!Array.isArray(values)) {
throw new Error('Invalid serialized tx input: must be array')
}
return BlobEIP4844Transaction.fromValuesArray(values as TxValuesArray, opts)
}
/**
* Create a transaction from a values array.
*
* Format: `[chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
* accessList, signatureYParity, signatureR, signatureS]`
*/
public static fromValuesArray(values: TxValuesArray, opts: TxOptions = {}) {
if (opts.common?.customCrypto?.kzg === undefined) {
throw new Error(
'A common object with customCrypto.kzg initialized required to instantiate a 4844 blob tx'
)
}
if (values.length !== 11 && values.length !== 14) {
throw new Error(
'Invalid EIP-4844 transaction. Only expecting 11 values (for unsigned tx) or 14 values (for signed tx).'
)
}
const [
chainId,
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
gasLimit,
to,
value,
data,
accessList,
maxFeePerBlobGas,
blobVersionedHashes,
v,
r,
s,
] = values
this._validateNotArray({ chainId, v })
validateNoLeadingZeroes({
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
gasLimit,
value,
maxFeePerBlobGas,
v,
r,
s,
})
return new BlobEIP4844Transaction(
{
chainId: bytesToBigInt(chainId),
nonce,
maxPriorityFeePerGas,
maxFeePerGas,
gasLimit,
to,
value,
data,
accessList: accessList ?? [],
maxFeePerBlobGas,
blobVersionedHashes,
v: v !== undefined ? bytesToBigInt(v) : undefined, // EIP2930 supports v's with value 0 (empty Uint8Array)
r,
s,
},
opts
)
}
/**
* Creates a transaction from the network encoding of a blob transaction (with blobs/commitments/proof)
* @param serialized a buffer representing a serialized BlobTransactionNetworkWrapper
* @param opts any TxOptions defined
* @returns a BlobEIP4844Transaction
*/
public static fromSerializedBlobTxNetworkWrapper(
serialized: Uint8Array,
opts?: TxOptions
): BlobEIP4844Transaction {
if (!opts || !opts.common) {
throw new Error('common instance required to validate versioned hashes')
}
if (opts.common?.customCrypto?.kzg === undefined) {
throw new Error(
'A common object with customCrypto.kzg initialized required to instantiate a 4844 blob tx'
)
}
if (
equalsBytes(serialized.subarray(0, 1), txTypeBytes(TransactionType.BlobEIP4844)) === false
) {
throw new Error(
`Invalid serialized tx input: not an EIP-4844 transaction (wrong tx type, expected: ${
TransactionType.BlobEIP4844
}, received: ${bytesToHex(serialized.subarray(0, 1))}`
)
}
// Validate network wrapper
const networkTxValues = RLP.decode(serialized.subarray(1))
if (networkTxValues.length !== 4) {
throw Error(`Expected 4 values in the deserialized network transaction`)
}
const [txValues, blobs, kzgCommitments, kzgProofs] =
networkTxValues as BlobEIP4844NetworkValuesArray
// Construct the tx but don't freeze yet, we will assign blobs etc once validated
const decodedTx = BlobEIP4844Transaction.fromValuesArray(txValues, { ...opts, freeze: false })
if (decodedTx.to === undefined) {
throw Error('BlobEIP4844Transaction can not be send without a valid `to`')
}
const version = Number(opts.common.param('sharding', 'blobCommitmentVersionKzg'))
validateBlobTransactionNetworkWrapper(
decodedTx.blobVersionedHashes,
blobs,
kzgCommitments,
kzgProofs,
version,
opts.common.customCrypto.kzg
)
// set the network blob data on the tx
decodedTx.blobs = blobs
decodedTx.kzgCommitments = kzgCommitments
decodedTx.kzgProofs = kzgProofs
// freeze the tx
const freeze = opts?.freeze ?? true
if (freeze) {
Object.freeze(decodedTx)
}
return decodedTx
}
/**
* The amount of gas paid for the data in this tx
*/
getDataFee(): bigint {
return EIP2930.getDataFee(this)
}
/**
* The up front amount that an account must have for this transaction to be valid
* @param baseFee The base fee of the block (will be set to 0 if not provided)
*/
getUpfrontCost(baseFee: bigint = BIGINT_0): bigint {
return EIP1559.getUpfrontCost(this, baseFee)
}
/**
* Returns a Uint8Array Array of the raw Bytes of the EIP-4844 transaction, in order.
*
* Format: [chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data,
* access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, s]`.
*
* Use {@link BlobEIP4844Transaction.serialize} to add a transaction to a block
* with {@link createBlockFromValuesArray}.
*
* For an unsigned tx this method uses the empty Bytes values for the
* signature parameters `v`, `r` and `s` for encoding. For an EIP-155 compliant
* representation for external signing use {@link BlobEIP4844Transaction.getMessageToSign}.
*/
raw(): TxValuesArray {
return [
bigIntToUnpaddedBytes(this.chainId),
bigIntToUnpaddedBytes(this.nonce),
bigIntToUnpaddedBytes(this.maxPriorityFeePerGas),
bigIntToUnpaddedBytes(this.maxFeePerGas),
bigIntToUnpaddedBytes(this.gasLimit),
this.to !== undefined ? this.to.bytes : new Uint8Array(0),
bigIntToUnpaddedBytes(this.value),
this.data,
this.accessList,
bigIntToUnpaddedBytes(this.maxFeePerBlobGas),
this.blobVersionedHashes,
this.v !== undefined ? bigIntToUnpaddedBytes(this.v) : new Uint8Array(0),
this.r !== undefined ? bigIntToUnpaddedBytes(this.r) : new Uint8Array(0),
this.s !== undefined ? bigIntToUnpaddedBytes(this.s) : new Uint8Array(0),
]
}
/**
* Returns the serialized encoding of the EIP-4844 transaction.
*
* Format: `0x03 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
* access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, s])`.
*
* Note that in contrast to the legacy tx serialization format this is not
* valid RLP any more due to the raw tx type preceding and concatenated to
* the RLP encoding of the values.
*/
serialize(): Uint8Array {
return EIP2718.serialize(this)
}
/**
* @returns the serialized form of a blob transaction in the network wrapper format (used for gossipping mempool transactions over devp2p)
*/
serializeNetworkWrapper(): Uint8Array {
if (
this.blobs === undefined ||
this.kzgCommitments === undefined ||
this.kzgProofs === undefined
) {
throw new Error(
'cannot serialize network wrapper without blobs, KZG commitments and KZG proofs provided'
)
}
return EIP2718.serialize(this, [this.raw(), this.blobs, this.kzgCommitments, this.kzgProofs])
}
/**
* Returns the raw serialized unsigned tx, which can be used
* to sign the transaction (e.g. for sending to a hardware wallet).
*
* Note: in contrast to the legacy tx the raw message format is already
* serialized and doesn't need to be RLP encoded any more.
*
* ```javascript
* const serializedMessage = tx.getMessageToSign() // use this for the HW wallet input
* ```
*/
getMessageToSign(): Uint8Array {
return EIP2718.serialize(this, this.raw().slice(0, 11))
}
/**
* Returns the hashed serialized unsigned tx, which can be used
* to sign the transaction (e.g. for sending to a hardware wallet).
*
* Note: in contrast to the legacy tx the raw message format is already
* serialized and doesn't need to be RLP encoded any more.
*/
getHashedMessageToSign(): Uint8Array {
return EIP2718.getHashedMessageToSign(this)
}
/**
* Computes a sha3-256 hash of the serialized tx.
*
* This method can only be used for signed txs (it throws otherwise).
* Use {@link BlobEIP4844Transaction.getMessageToSign} to get a tx hash for the purpose of signing.
*/
public hash(): Uint8Array {
return Legacy.hash(this)
}
getMessageToVerifySignature(): Uint8Array {
return this.getHashedMessageToSign()
}
/**
* Returns the public key of the sender
*/
public getSenderPublicKey(): Uint8Array {
return Legacy.getSenderPublicKey(this)
}
/**
* Returns the EIP 4844 transaction network wrapper in JSON format similar to toJSON, including
* blobs, commitments, and proofs fields
* @param serialized a buffer representing a serialized BlobTransactionNetworkWrapper
* @param opts any TxOptions defined
* @returns JsonBlobTxNetworkWrapper with blobs, KZG commitments, and KZG proofs fields
*/
public static networkWrapperToJson(
serialized: Uint8Array,
opts?: TxOptions
): JsonBlobTxNetworkWrapper {
const tx = this.fromSerializedBlobTxNetworkWrapper(serialized, opts)
const accessListJSON = AccessLists.getAccessListJSON(tx.accessList)
const baseJson = tx.toJSON()
return {
...baseJson,
chainId: bigIntToHex(tx.chainId),
maxPriorityFeePerGas: bigIntToHex(tx.maxPriorityFeePerGas),
maxFeePerGas: bigIntToHex(tx.maxFeePerGas),
accessList: accessListJSON,
maxFeePerBlobGas: bigIntToHex(tx.maxFeePerBlobGas),
blobVersionedHashes: tx.blobVersionedHashes.map((hash) => bytesToHex(hash)),
blobs: tx.blobs!.map((bytes) => bytesToHex(bytes)),
kzgCommitments: tx.kzgCommitments!.map((bytes) => bytesToHex(bytes)),
kzgProofs: tx.kzgProofs!.map((bytes) => bytesToHex(bytes)),
}
}
toJSON(): JsonTx {
const accessListJSON = AccessLists.getAccessListJSON(this.accessList)
const baseJson = super.toJSON()
return {
...baseJson,
chainId: bigIntToHex(this.chainId),
maxPriorityFeePerGas: bigIntToHex(this.maxPriorityFeePerGas),
maxFeePerGas: bigIntToHex(this.maxFeePerGas),
accessList: accessListJSON,
maxFeePerBlobGas: bigIntToHex(this.maxFeePerBlobGas),
blobVersionedHashes: this.blobVersionedHashes.map((hash) => bytesToHex(hash)),
}
}
addSignature(
v: bigint,
r: Uint8Array | bigint,
s: Uint8Array | bigint,
convertV: boolean = false
): BlobEIP4844Transaction {
r = toBytes(r)
s = toBytes(s)
const opts = { ...this.txOptions, common: this.common }
return BlobEIP4844Transaction.fromTxData(
{
chainId: this.chainId,
nonce: this.nonce,
maxPriorityFeePerGas: this.maxPriorityFeePerGas,
maxFeePerGas: this.maxFeePerGas,
gasLimit: this.gasLimit,
to: this.to,
value: this.value,
data: this.data,
accessList: this.accessList,
v: convertV ? v - BIGINT_27 : v, // This looks extremely hacky: @ethereumjs/util actually adds 27 to the value, the recovery bit is either 0 or 1.
r: bytesToBigInt(r),
s: bytesToBigInt(s),
maxFeePerBlobGas: this.maxFeePerBlobGas,
blobVersionedHashes: this.blobVersionedHashes,
blobs: this.blobs,
kzgCommitments: this.kzgCommitments,
kzgProofs: this.kzgProofs,
},
opts
)
}
/**
* Return a compact error string representation of the object
*/
public errorStr() {
let errorStr = this._getSharedErrorPostfix()
errorStr += ` maxFeePerGas=${this.maxFeePerGas} maxPriorityFeePerGas=${this.maxPriorityFeePerGas}`
return errorStr
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string) {
return Legacy.errorMsg(this, msg)
}
/**
* @returns the number of blobs included with this transaction
*/
public numBlobs(): number {
return this.blobVersionedHashes.length
}
}