Last active
March 13, 2022 22:08
-
-
Save lajosdeme/e07f6714114805cb34a2e75556ac017e to your computer and use it in GitHub Desktop.
My simple Hardhat setup script for my Solidity projects. It downloads hardhat via npm, creates folders, and installs a few of my favourite plugins.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Simple script to preapre a project for smart contract development with hardhat. | |
# author: lajosdeme | |
# This will create an npm project, create folders for contracts, tests and scripts, and install the following dependencies: | |
# · hardhat | |
# · @openzeppelin/contracts | |
# · @nomiclabs/hardhat-ethers | |
# · @nomiclabs/hardhat-waffle | |
# · chai | |
# · ethers | |
# · ethereum-waffle | |
# · hardhat-contract-sizer | |
# · hardhat-gas-reporter | |
# · hardhat-spdx-license-identifier | |
if [ "$1" == "" ]; then | |
echo "Usage: setup-hardhat <Solidity compiler version>" | |
exit 1 | |
fi | |
npm init -y | |
echo "Installing hardhat..." | |
npm i hardhat | |
echo "Installing open zeppelin..." | |
npm i @openzeppelin/contracts | |
echo "Installing dev dependencies..." | |
echo "Installing ardhat-ethers, hardhat-waffle..." | |
npm i --save-dev @nomiclabs/hardhat-ethers @nomiclabs/hardhat-waffle | |
echo "Installing chai..." | |
npm i --save-dev chai | |
echo "Installing ethereum-waffle..." | |
npm i --save-dev ethereum-waffle | |
echo "Installing ethers..." | |
npm i --save-dev ethers | |
echo "Installing contract sizer, gas reporter, spdx identifier..." | |
npm i --save-dev hardhat-contract-sizer hardhat-gas-reporter hardhat-spdx-license-identifier | |
echo "Creating folders..." | |
mkdir contracts tests scripts | |
echo "Creating empty deploy script file..." | |
touch scripts/deploy.js | |
echo " | |
require(\"@nomiclabs/hardhat-waffle\"); | |
require(\"hardhat-contract-sizer\"); | |
require(\"@nomiclabs/hardhat-truffle5\"); | |
require(\"hardhat-gas-reporter\"); | |
require(\"hardhat-spdx-license-identifier\"); | |
task(\"accounts\", \"Prints the list of accounts\", async (taskArgs, hre) => { | |
const accounts = await hre.ethers.getSigners(); | |
for (const account of accounts) { | |
console.log(account.address); | |
} | |
}); | |
module.exports = { | |
solidity: { | |
version: \""$1"\", | |
settings: { | |
optimizer: { | |
enabled: true, | |
runs: 200 | |
} | |
} | |
}, | |
contractSizer: { | |
alphasort: false, | |
disambiguatePaths: false, | |
runOnCompile: true, | |
strict: false | |
}, | |
gasReporter: { | |
enabled: true, | |
currency: 'USD', | |
coinmarketcap: \"\", | |
gasPrice: 70, | |
}, | |
spdxLicenseIdentifier: { | |
overwrite: false, | |
runOnCompile: true, | |
} | |
}; | |
" > hardhat.config.js | |
echo "Hardhat project successfully set up and ready to build. 👷🏿♂️👷♀️" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment