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
contracts/
directory by making changes in the same file
Example1
- Stores certain variables such as
day
,amount
andownerAddr
- Stores certain variables such as
Example2
- Stores a state variable
counter
. FunctionincrementBy
takes in an array and adds each element of this array to counter variable
- Stores a state variable
Example3
- Stores a state variable
marginPercentage
. FunctiongetOwnerMargin
takes in an amount and returns respective amounts for owner and sender
- Stores a state variable
-
Create a fork of this repo
-
Install all dependencies
npm install
-
Make changes to contracts in this directory -
contract/
. The tests intest/
directory should run successfully. -
Run Tests
npm test
-
Create a pull request from your forked repo to main branch of original repo to run the github workflow. The name of the pull request should be in the format YOUR_NAME - Gas Optimization Assignment