-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhardhat.config.js
More file actions
124 lines (114 loc) · 4.32 KB
/
hardhat.config.js
File metadata and controls
124 lines (114 loc) · 4.32 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
require("dotenv").config();
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-chai-matchers");
require("@nomiclabs/hardhat-ethers");
require("@nomicfoundation/hardhat-network-helpers");
require("hardhat-contract-sizer");
require("hardhat-abi-exporter");
require("@openzeppelin/hardhat-upgrades");
const { task } = require("hardhat/config");
const deploymentAddress = require("./scripts/deployment/deploymentAddresses.json");
const bridgeArtifacts = require("./artifacts/contracts/EthErc20FastBridge.sol/EthErc20FastBridge.json");
require('hardhat-storage-layout');
const PRIVATE_KEYS = process.env.PRIVATE_KEYS ? process.env.PRIVATE_KEYS.split(",") : [];
const PRIVATE_KEY = process.env.PRIVATE_KEY || "11".repeat(32);
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
const INFURA_API_KEY = process.env.INFURA_API_KEY;
const FORKING = true;
const ENABLED_OPTIMIZER = true;
const OPTIMIZER_RUNS = 200;
task("method", "Execute Fastbridge methods")
.addParam("jsonstring", "JSON string with function signature and arguments")
.setAction(async (taskArgs) => {
const network = (await ethers.getDefaultProvider().getNetwork()).name;
const bridgeAddress = deploymentAddress[network].new.bridge;
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_TASK);
const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const jsonString = taskArgs.jsonstring;
const json = JSON.parse(jsonString);
const arg = json.arguments;
const methodName = json.methodname;
const gasLimit = json.gaslimit;
console.log(arg);
const methodArguments = Object.values(arg);
console.log(methodName, methodArguments);
const contractInterface = new ethers.utils.Interface(bridgeArtifacts.abi);
// Send the transaction
const txdata = contractInterface.encodeFunctionData(methodName, methodArguments);
const tx = await signer.sendTransaction({
to: bridgeAddress,
data: txdata,
gasLimit: gasLimit
});
console.log(tx);
await tx.wait();
console.log("Transaction mined!");
});
module.exports = {
solidity: {
version: "0.8.11",
settings: {
optimizer: {
enabled: ENABLED_OPTIMIZER,
runs: OPTIMIZER_RUNS
},
metadata: {
// do not include the metadata hash, since this is machine dependent
// and we want all generated code to be deterministic
// https://docs.soliditylang.org/en/v0.8.11/metadata.html
bytecodeHash: "none"
}
}
},
networks: {
hardhat: {
allowUnlimitedContractSize: !ENABLED_OPTIMIZER,
forking: {
url: process.env.FORKING_URL || `https://mainnet.infura.io/v3/${INFURA_API_KEY}`,
enabled: FORKING !== undefined
}
},
mainnet: {
url: process.env.MAINNET_URL || "",
accounts: [...PRIVATE_KEYS]
},
rinkeby: {
url: process.env.RINKEBY_URL || "",
accounts: [...PRIVATE_KEYS]
},
ropsten: {
url: process.env.ROPSTEN_URL || "",
accounts: [...PRIVATE_KEYS]
},
kovan: {
url: process.env.KOVAN_URL || "",
accounts: [...PRIVATE_KEYS]
},
goerli: {
url: INFURA_API_KEY
? `https://goerli.infura.io/v3/${INFURA_API_KEY}`
: `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts: [`${PRIVATE_KEY}`]
}
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
outputFile: process.env.GAS_REPORT_TO_FILE ? "gas-report.txt" : undefined
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
url: process.env.ETHERSCAN_URL || ""
},
contractSizer: {
except: ["mocks/"]
},
abiExporter: {
pretty: true,
except: ["interfaces/", "mocks/"]
}
};
if (process.env.FORKING_BLOCK_NUMBER)
module.exports.networks.hardhat.forking.blockNumber = +process.env.FORKING_BLOCK_NUMBER;
if (process.env.HARDFORK)
module.exports.networks.hardhat.hardfork = process.env.HARDFORK;