The goal of this exercise is to optimize contracts for minimal gas usage. This assignment contains 3 tasks in form of gas optimization examples. For each task your goal is to reduce the gas usage as much as possible
- Optimize each contract in
src/
directory by making changes in the same file
Storage
- Stores certain variables such as
day
,amount
andownerAddr
- Stores certain variables such as
ArrayIncrement
- Stores a state variable
counter
. FunctionincrementBy
takes in an array and adds each element of this array to counter variable
- Stores a state variable
MarginCalculator
- Stores a state variable
marginPercentage
. FunctiongetOwnerMargin
takes in an amount and returns respective amounts for owner and sender
- Stores a state variable
Lock
- Determines if the contract is locked or not on the basis of value stored in
locked
variable
- Determines if the contract is locked or not on the basis of value stored in
Dispenser
- Stores the ether received during initialisation
- It has a waiting period of 3 days before the funds are dispensed to all three receivers
-
Clone this repo. Use the flag
--recurse-submodules
to clone the repo along with the submodules.git clone --recurse-submodules https://github.com/DappCamp-Assignments/18eafad48d6430a98c013ab7ef75632b450358e0c035ec3288be4f41186a1527/tree/master
-
Install
forge-std
library using the below commandforge install foundry-rs/forge-std --no-commit
-
Create a new branch with your name. You can use the following command
git checkout -b my-name
-
Make changes to contracts in this directory -
src/
. The tests intest/
directory should run successfully. -
Run Tests
forge test
-
Create a pull request from your branch to the main branch of original repo to run the github workflow.