Configuration

Default Configuration

Parasol can be customized to the lowest level using its config file parasol.js.

The file exports an object of configuration properties and methods to the parasol cli tool to manipulate its functionality and the functionality of its dependencies. Here's the default config file:

module.exports = {
dev: { // Ganache-cli options (https://github.com/trufflesuite/ganache-cli)
port:8555,
total_accounts:10,
locked:false,
debug:false,
//logger:console,
gasPrice: 0
},
contracts : "*", // To select specific contract locations, replace it with an array: ["File1.sol", "Folder/File2.sol"]
solc: { // Solidity compiler options (https://solidity.readthedocs.io/en/develop/using-the-compiler.html)
optimizer: {
enabled: true,
// Optimize for how many times you intend to run the code.
// Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage.
runs: 200
},
evmVersion: "byzantium", // Version of the EVM to compile for. Affects type checking and code generation. Can be homestead, tangerineWhistle, spuriousDragon, byzantium or constantinople
// UNCOMMENT IF USING LIBRARIES: Addresses of the libraries. If not all libraries are given here, it can result in unlinked objects whose output data is different.
// libraries: {
// // The top level key is the the name of the source file where the library is used.
// // If remappings are used, this source file should match the global path after remappings were applied.
// // If this key is an empty string, that refers to a global level.
// "myFile.sol": {
// "MyLib": "0x123123..."
// }
// },
outputSelection: {
"*": {
"*": [ "metadata", "evm.bytecode", "devdoc" ]
}
}
},
preprocessor: {
context: {
title: "A minimal token contract",
tokenSupply: "1*10**28",
tokenName: "Token",
tokenDecimals:18,
tokenSymbol: "TOK"
},
settings: { // Underscore.js.template settings. Read more: https://underscorejs.org/#template
evaluate: /{{([\s\S]+?)}}/g,
interpolate: /{{=([\s\S]+?)}}/g,
escape: /{{-([\s\S]+?)}}/g
},
strict: false // If true, strict mode will abort deployment on warnings as well as errors
},
deployer: async function (contracts, network, web3, test, save) {
for (var contract in contracts) {
var gasPrice = "50000000000"; //50 Gwei
if(network === "dev") {
gasPrice = "0";
}
contracts[contract] = await contracts[contract].deploy().send({from: web3.eth.accounts[0], gasPrice, gas:6000000})
console.log(("Contract " + contract + " deployed at address " + contracts[contract].options.address).green)
}
save(contracts) // Saves contract addresses to addressbook.json. Development addresses will never be saved to addressbook.
test(contracts) // Call the test function if you want to run unit tests after deployment. Tests will only run if network is dev
}
}

Usage

Here's the explanation of the above configuration object:

dev Object

Development environment configuration file passed directly to ganache when running parasol

contracts Array|String

List of all contracts to be compiled, documented tested and deployed. Items must be file locations relative to the contracts/ folder. Example: ['Token.sol'].

preprocessor Object

Psol preprocessor configuration object. For more information, visit the Preprocessor page.

solc Object

Solidity compiler configuration file passed directly to solc-js

deployer(contracts Object, network String, web3 Object, test(contracts, network) Function) Function

Functions deployment handler. Handles all contract deployment across all networks including development. It is also responsible for passing contracts back to Parasol after deployment using the test() function for potential unit tests execution if the current network is dev.

  • The first arguments is an object of contract instances to be deployed. Key is of the same syntax as unit tests contract object:relative location from contracts folder + ":" + contract name.

  • The second argument is a string representing the name of the current network selected by the user. If parasol is running, the network variable will always be dev. If the deploy [network] argument is used instead, the network variable will take the value of [network]. This can be used to provide the hostname and port of a private network or node to the deployer from the command line (e.g. parasol deploy http://localhost:8540).

  • The third argument is a web3 1.0 object already populated with either ganache-generated accounts (in case of parasol) or accounts imported from private keys at secrets.json if using parasol deploy. Additionally, if the user specified a network that matches the name of any of INFURA's five networks, web3 will be attached to the appropriate INFURA node.

  • The fourth argument is a function that takes one argument:

    contracts which has to be an object of the same structure as the provided contracts variable but includes deployed contract instances instead.

  • The fifth argument is a function that also takes the same argument as the fourth.

Note: Because aesthetics are important, the colors package is already imported to the configuration file. You can use it by simply appending a color's name a property to any string. Example: 'success'.green