Skip to content

Commit a9a709e

Browse files
committed
tx: small adjustments to 7702 tx example2
1 parent 060f690 commit a9a709e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

packages/tx/examples/EOACodeTx.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
2-
import { createEOACode7702Tx } from '@ethereumjs/tx'
3-
import { type PrefixedHexString, createAddressFromPrivateKey, randomBytes } from '@ethereumjs/util'
2+
import { Capability, createEOACode7702Tx } from '@ethereumjs/tx'
3+
import {
4+
EOACode7702AuthorizationListItem,
5+
type PrefixedHexString,
6+
createAddressFromPrivateKey,
7+
randomBytes,
8+
} from '@ethereumjs/util'
49

5-
const ones32 = `0x${'01'.repeat(32)}` as PrefixedHexString
10+
const ones32: PrefixedHexString = `0x${'01'.repeat(32)}`
11+
const authorizationListItem: EOACode7702AuthorizationListItem = {
12+
chainId: '0x2',
13+
address: `0x${'20'.repeat(20)}`,
14+
nonce: '0x1',
15+
yParity: '0x1',
16+
r: ones32,
17+
s: ones32,
18+
}
619

7-
const common = new Common({ chain: Mainnet, hardfork: Hardfork.Cancun, eips: [7702] })
20+
const common = new Common({ chain: Mainnet, hardfork: Hardfork.Prague })
821
const tx = createEOACode7702Tx(
922
{
10-
authorizationList: [
11-
{
12-
chainId: '0x2',
13-
address: `0x${'20'.repeat(20)}`,
14-
nonce: '0x1',
15-
yParity: '0x1',
16-
r: ones32,
17-
s: ones32,
18-
},
19-
],
23+
authorizationList: [authorizationListItem],
2024
to: createAddressFromPrivateKey(randomBytes(32)),
2125
},
2226
{ common },
@@ -25,3 +29,4 @@ const tx = createEOACode7702Tx(
2529
console.log(
2630
`EIP-7702 EOA code tx created with ${tx.authorizationList.length} authorization list item(s).`,
2731
)
32+
console.log('Tx supports EIP-7702? ', tx.supports(Capability.EIP7702EOACode))

0 commit comments

Comments
 (0)