This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
truffle-config.js
executable file
·74 lines (62 loc) · 2.26 KB
/
truffle-config.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
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
const truffleConfig = require("@gnosis.pm/util-contracts/src/util/truffleConfig")
const argv = require("yargs").help(false).version(false).option("network", {
type: "string",
}).argv
const DEFAULT_GAS_LIMIT = 6e6
const DEFAULT_GAS_PRICE_GWEI = 5
const DEFAULT_MNEMONIC = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"
// Load env vars
require("dotenv").config()
// Get the mnemonic
const privateKey = process.env.PK
let mnemonic = process.env.MNEMONIC
if (!privateKey && !mnemonic) {
mnemonic = DEFAULT_MNEMONIC
}
// Solc
let solcUseDocker = process.env.SOLC_USE_DOCKER === "true" || false
let solcVersion = "0.5.6"
// Gas price
const gasPriceGWei = process.env.GAS_PRICE_GWEI || DEFAULT_GAS_PRICE_GWEI
// Gas limit
const gas = process.env.GAS_LIMIT || DEFAULT_GAS_LIMIT
// Allow to add an additional network (useful for docker-compose setups)
// i.e. NETWORK='{ "name": "docker", "networkId": "99999", "url": "http://rpc:8545", "gas": "6700000", "gasPrice": "25000000000" }'
let additionalNetwork = process.env.NETWORK ? JSON.parse(process.env.NETWORK) : null
const urlDevelopment = process.env.GANACHE_HOST || "localhost"
// network key
const infuraKey = process.env.INFURA_KEY
if ((argv.network === "rinkeby" || argv.network === "mainnet") && !infuraKey) {
console.log("Error: no Infura key found! You can create a new project key after registering an account at https://infura.io/")
process.exit(1)
}
const { gas: gasLog } = require("minimist")(process.argv.slice(2), { alias: { gas: "g" } })
module.exports = {
...truffleConfig({
mnemonic,
privateKey,
urlRinkeby: "https://rinkeby.infura.io/v3/".concat(infuraKey),
urlKovan: "https://kovan.infura.io/v3/".concat(infuraKey),
urlMainnet: "https://mainnet.infura.io/v3/".concat(infuraKey),
urlDevelopment,
gasPriceGWei,
gas,
additionalNetwork,
optimizedEnabled: true,
solcUseDocker,
solcVersion,
}),
// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
mocha: {
reporter: gasLog ? "eth-gas-reporter" : "spec",
reporterOptions: {
currency: "USD",
gasPrice: 20,
showTimeSpent: true,
},
},
plugins: ["truffle-plugin-verify"],
api_keys: {
etherscan: process.env.MY_ETHERSCAN_API_KEY,
},
}