-
Notifications
You must be signed in to change notification settings - Fork 0
/
ganache.ts
39 lines (33 loc) · 928 Bytes
/
ganache.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
import ganache = require("ganache");
import * as ethers from "ethers";
async function main() {
const options: ganache.ServerOptions<"ethereum"> = {
gasPrice: 0,
gasLimit: Number.MAX_SAFE_INTEGER,
allowUnlimitedContractSize: true,
vmErrorsOnRPCResponse: false, // Consistent with Besu
hardfork: "berlin",
chain: {
asyncRequestProcessing: true,
},
logging: {
verbose: false,
},
miner: {
instamine: "strict",
},
};
// @ts-ignore
const server = ganache.server(options);
server.listen(8777, function () {
console.log(`Ethereum RPC listening on port 8777`);
// @ts-ignore
const provider = new ethers.providers.Web3Provider(server.provider);
provider.pollingInterval = 100;
provider.on("block", async (n) => {
const block = await provider.getBlock(n);
console.log(block);
});
});
}
main().catch((e) => console.log(e));