-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.ts
53 lines (40 loc) · 1.4 KB
/
example.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
import { createSimulator } from ".";
const mainProvider = process.env.PROVIDER!;
const run = async () => {
let simulator = await createSimulator(
mainProvider,
"Reth"
);
// Create new fork to simulate on
const fork = await simulator.fork();
const alice = "0xac1872e0701E1DF6c302Fad31902dd67DA121B8E";
const bob = "0x850FC93BA787E49C795b86BD0feD4d87d7342518";
console.log("Alice balance:", await fork.getBalance(alice));
console.log("Bob balance:", await fork.getBalance(bob));
// give ourselves some ether
await fork.setBalance(alice, 100n * 10n ** 18n);
console.log("Alice balance:", await fork.getBalance(alice));
// Send some ether from alice to bob
const executionResult = await fork.commitTx(
{
from: alice,
to: bob,
value: 10n * 10n ** 18n,
data: "0x"
},
logData => {
// Called if any logs are emitted during the execution
}
)
console.log("Alice balance:", await fork.getBalance(alice));
console.log("Bob balance:", await fork.getBalance(bob));
console.log(
"Execution result:",
executionResult.receipt.status === 1 // true if the transaction was successful
);
await simulator.preload([
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"0xdac17f958d2ee523a2206206994597c13d831ec7"
])
}
run()