-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (38 loc) · 1.34 KB
/
index.js
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
const ganache = require("ganache")
const ethers = require("ethers")
// Infura API:
const provider = new ethers.providers.InfuraProvider("homestead", {
projectId: "fd6b6e1b7a11464194d26f2557547a43",
projectSecret: "6b18ba05af774338880442c47b9b6bf4"
});
const url = provider.connection.url
// QuickNode API:
// const url = "https://fragrant-green-frost.quiknode.pro/9ccea4706b2f6d1b43455815cabcfb453acaf748";
// const provider = new ethers.providers.JsonRpcProvider(url);
// Ganache server options:
const ganache_options = {
fork: {
url: url,
requestsPerSecond: 5 // the number of requests per second sent to the fork provider
},
wallet: {
unlockedAccounts: [
"0xd8da6bf26964af9d7eed9e03e53415d37aa96045", // unlock vitalik.eth to impersonate :)
]
}
};
// Restart ganache server on every new block mined.
provider.on('block', function(blockNumber) {
console.time('Ganache Restart Time Used')
server.close();
console.log("Firing off new local ganache fork @block #", blockNumber)
server = ganache.server(ganache_options);
server.listen(1337);
console.timeEnd('Ganache Restart Time Used')
});
main = () => {
console.log("Firing off local ganache fork, server access: http://127.0.0.1:1337")
server = ganache.server(ganache_options);
server.listen(1337);
}
main()