Gas optimization is a critical aspect of developing efficient and cost-effective smart contracts on blockchain platforms. We recognize the importance of gas efficiency in enabling widespread adoption of blockchain-based applications.
This bounty aims to support optimizing gas usage for thirdweb's published smart contracts, enhancing their performance, scalability, and cost-effectiveness.
Objectives: The primary objective of this bounty is to encourage the development of gas-optimized versions of thirdweb's published smart contracts. The bounty recipients will be expected to achieve the following goals:
Gas Efficiency: Identify and implement strategies to reduce gas consumption and improve the overall efficiency of thirdweb's published smart contracts. This includes optimizing contract logic, reducing unnecessary storage operations, minimizing computational complexity, and improving code structure and design.
Steps on how to get started are detailed as followed:
Benchmarking and Testing: The proposed changes must be tested using thirdweb’s benchmark tests. Optionally, you may also add and run your own tests.
Steps on how to run thirdweb’s benchmark tests are detailed as followed:
forge build
, followed by yarn gas
. You’ll now see a diff in the gasreport.txt
file, for how your optimizations affected gas consumption. Commit this change with the commit message “yarn gas”.Selected applicants will receive financial support in return for suggested gas improvements. The reward will be classified in three tiers:
Low
- $250+. Percentage of total gas saved is between 5-15%.Medium
- $1,000+. Percentage of total gas saved is between 15-40%.High
- $2,500+ Percentage of total gas saved is 40% or more.This reward is calculated based on the total % of gas you’ve reduced across all contracts you’ve optimized. For each contract, we will only consider optimizations made to “relevant functions”. These are functions present in the benchmark test files in contracts/src/test/benchmark/*
.
How to calculate my reward?
Let’s say you’ve reduced the gas of ExampleContractA.function
from 100
→ 80
gas, and ExampleContractB.function
from 50
→ 40
gas.
Your reward is calculated based on the total % of gas you’ve reduced across all contracts you’ve optimized.
percentageOptimized = ((total_gas_before - tota_gas_after) / total_gas_before ) * 100
So in this example case:
percentageOptimized = ((150 - 120) / 150) * 100 = 20 %
The percentage optimized is 20 %
, which would qualify the optimization for the Medium
category of reward payout.