-
Notifications
You must be signed in to change notification settings - Fork 13
/
create.js
48 lines (42 loc) · 1.5 KB
/
create.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
45
46
47
48
require("dotenv").config();
const { TenderlyFork } = require("./tenderly");
const ETH_ADDRESS = process.env.ETH_ADDRESS;
const fork = new TenderlyFork();
const CHAIN_ID = process.env.CHAIN_ID || 3030;
const FORK_NETWORK_ID = process.env.FORK_NETWORK_ID || "1";
async function main() {
await fork.init(FORK_NETWORK_ID, CHAIN_ID);
console.log("rpcUrl", fork.get_rpc_url());
console.log("chainId", CHAIN_ID);
console.log("");
if (ETH_ADDRESS) {
console.log(`Funding ${ETH_ADDRESS} with 10000 of the native currency.`);
await fork.fund_account(ETH_ADDRESS, 10000);
} else {
console.log("No ETH_ADDRESS was provided so funding is skipped.");
}
console.log(
"To use this fork on the aave interface type the following commands in the console."
);
console.log("--------------");
console.log(`localStorage.setItem('forkEnabled', 'true');`);
console.log(`localStorage.setItem('forkBaseChainId', ${FORK_NETWORK_ID});`);
console.log(`localStorage.setItem('forkNetworkId', ${CHAIN_ID});`);
console.log(`localStorage.setItem("forkRPCUrl", "${fork.get_rpc_url()}");`);
console.log("--------------");
console.log("warning: the fork will be deleted once this terminal is closed");
}
main().catch(function (err) {
console.error(err);
process.exit(1);
});
// keep process alive
process.stdin.resume();
// delete fork on exit
process.on("SIGINT", function () {
console.log("Caught interrupt signal");
fork.deleteFork().then((d) => {
console.log("fork deleted");
process.exit(0);
});
});