dApp that supports EthWord
payment, a micropayments channel.
├── index.html
├── package.json
├── README.md
├── src
│ ├── App.tsx # Here is the file with the UI
│ ├── components
│ │ ├── [...]
│ ├── generated.ts # Generated from wagmi-cli
│ ├── index.css
│ ├── main.tsx # Main file, changes on it make changes on all components
│ ├── vite-env.d.ts
│ └── wagmi.ts # wagmi config.ts file
├── tsconfig.json
├── tsconfig.node.json
├── vite.config.ts
└── wagmi.config.ts # wagmi-cli config file
The file system and the file names are self-explanatory.
.
├── contracts
│ └── EthWord.sol
├── generate_json_for_plotting.sh
├── hardhat.config.ts
├── ignition
│ └── modules
│ └── EthWord.ts
├── package.json
├── package-lock.json
├── README.md
├── run_test_and_collect_data.sh
├── test
│ ├── ethword
│ │ ├── Channel.test.ts
│ │ ├── CloseChannel.test.ts
│ │ ├── Deploy.test.ts
│ │ ├── PartialClose.test.ts
│ │ └── User.test.ts
│ └── utils
│ └── deployEthWord.ts
└── tsconfig.json
First, ensure you are in the right folder:
cd hardhat
In one terminal, run the local blockchain:
npx hardhat node
In another terminal, deploy your contracts on the localhost network:
npx hardhat ignition deploy ignition/modules/EthWord.ts --network localhost
The output is the smart contract address. If you are using the Frontend, you need to manually set up this address in the .env
file. The default first address of Hardhat is:
0x5FbDB2315678afecb367f032d93F642f64180aa3
In some cases, you will need to set up the apikeys
in hardhat/hardhat.config.ts
.
ALCHEMY_API_KEY
--> needed to deploy to any networkPRIVATE_KEY
--> needed to deploy to any networkCOINMARKETCAP_API
--> needed to make the gas tests
To correctly set up these variables, use:
npx hardhat vars set ETHERSCAN_API_KEY
The default configuration will always generate a report. This is configured in hardhat.config.ts
to generate a JSON report:
gasReporter: {
enabled: true,
currency: "USD",
L1: "polygon",
offline: false,
// outputJSON: true,
// outputJSONFile: "out.json",
}
To run tests and generate a gas report:
npx hardhat test
This outputs gas usage of each function in your smart contracts to the terminal. Some additional setup can be done, such as exporting the report to JSON.
The run_test_and_collect_data.sh
script automates testing and capturing gas usage for various hash amounts in your smart contracts, saving the results to gas_data.csv
for analysis. The script will iterate through predefined hash amounts, run the tests, and generate a CSV file (gas_data.csv
) with the gas usage data.
jq
installed for JSON parsing
./run_test_and_collect_data.sh