forked from ethereumjs/ethereumjs-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6110Requests.ts
42 lines (38 loc) · 1.04 KB
/
6110Requests.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
import { createBlock, genRequestsTrieRoot } from '@ethereumjs/block'
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
import {
type CLRequest,
type CLRequestType,
bytesToBigInt,
createDepositRequest,
randomBytes,
} from '@ethereumjs/util'
const main = async () => {
const common = new Common({
chain: Mainnet,
hardfork: Hardfork.Prague,
})
const depositRequestData = {
pubkey: randomBytes(48),
withdrawalCredentials: randomBytes(32),
amount: bytesToBigInt(randomBytes(8)),
signature: randomBytes(96),
index: bytesToBigInt(randomBytes(8)),
}
const request = createDepositRequest(depositRequestData) as CLRequest<CLRequestType>
const requests = [request]
const requestsRoot = await genRequestsTrieRoot(requests)
const block = createBlock(
{
requests,
header: { requestsRoot },
},
{ common },
)
console.log(
`Instantiated block with ${
block.requests?.length
} deposit request, requestTrieValid=${await block.requestsTrieIsValid()}`,
)
}
void main()