Skip to content

Instantly share code, notes, and snippets.

@damianobarbati
Created January 29, 2024 12:45
Show Gist options
  • Save damianobarbati/d343c48cc86cc1fa42a9d05fb67d45f9 to your computer and use it in GitHub Desktop.
Save damianobarbati/d343c48cc86cc1fa42a9d05fb67d45f9 to your computer and use it in GitHub Desktop.
Start testnet and deploy application smart contract:
```sh
pnpm -F bcm hh:node
pnpm -F bcm hh:deploy --network localhost
```
Hardhat JSON RPC is served at <http://127.0.0.1:8545>.
```json
{
"name": "bcm",
"version": "1.0.0",
"license": "UNLICENSED",
"author": "Applied Blockchain Ltd <[email protected]> (https://github.com/appliedblockchain)",
"repository": "https://dev.azure.com/CRYOPDP/_git/Blockchain",
"type": "module",
"engines": {
"node": ">=21"
},
"scripts": {
"hh:test": "NODE_ENV=test REPORT_GAS=true hardhat test",
"hh:node": "hardhat node",
"hh:deploy": "hardhat run scripts/deploy.js",
"hh:compile": "hardhat compile",
"hh:script": "node -r envk"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.5",
"chai": "^4.3.10",
"envk": "^3.2.2",
"ethers": "^6.9.1",
"hardhat": "^2.19.4",
"mocha": "^10.2.0"
}
}
```
```js
// hardhat.config.cjs
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
compilers: [
{
version: '0.8.19',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
networks: {
hardhat: {
mining: {
auto: false,
interval: 10000,
},
},
localhost: {
url: 'http://localhost:8545/c1a575dd14ea1b5e7f6c72fd57a0e83f',
accounts: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'],
},
},
gasReporter: {
enabled: true,
},
};
// when we run tests, we are enabling auto-mining to not wait for contract deployment and tx mining
extendEnvironment(async (hre) => {
if (process.env.NODE_ENV === 'test') {
await hre.network.provider.send('evm_setAutomine', [true]);
await hre.network.provider.send('evm_setIntervalMining', [0]);
}
});
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment