Platform: Code4rena
Start Date: 17/03/2023
Pot Size: $36,500 USDC
Total HM: 10
Participants: 98
Period: 3 days
Judge: leastwood
Total Solo HM: 5
Id: 223
League: ETH
Rank: 95/98
Findings: 1
Award: $12.03
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xSmartContract
Also found by: 0xdaydream, 0xnev, Aymen0909, Deekshith99, Diana, EvanW, Fanz, JCN, Jerry0x, K42, Kresh, Madalad, MiniGlome, Polaris_tow, Rageur, ReyAdmirado, Rolezn, SAAJ, SaeedAlipoor01988, Sathish9098, Shubham, Udsen, Viktor_Cortess, Walter, anodaram, arialblack14, atharvasama, caspersolangii, codeslide, descharre, fatherOfBlocks, felipe, ginlee, igingu, lukris02, nadin, slvDev, tnevler, turvy_fuzz, viking71
12.034 USDC - $12.03
Issue | Instances | |
---|---|---|
GAS-1 | Use the payable modifier on constructor | 4 |
GAS-2 | Use immutable on state variables updated only in the constructor | 1 |
payable
modifier on constructorAdding the payable
modifier on constructor will simplify the initialization bytecode by removing the 'revert if msg.sender is not zero' check, resulting in cheaper contract deployment.
Saves 204 gas per instance
Instances (4):
File: canto-pfp-protocol/src/ProfilePicture.sol 57: constructor(address _cidNFT, string memory _subprotocolName) ERC721("Profile Picture", "PFP") {
File: canto-bio-protocol/src/Bio.sol 32: constructor() ERC721("Biography", "Bio") {
File: canto-namespace-protocol/src/Namespace.sol 73: constructor( 74: address _tray, 75: address _note, 76: address _revenueAddress 77: ) ERC721("Namespace", "NS") Owned(msg.sender) {
File: canto-namespace-protocol/src/Tray.sol 98: constructor( 99: bytes32 _initHash, 100: uint256 _trayPrice, 101: address _revenueAddress, 102: address _note, 103: address _namespaceNFT 104: ) ERC721A("Namespace Tray", "NSTRAY") Owned(msg.sender) {
immutable
on state variables updated only on the constructorImmutable
variables are compiled into the contract's runtime bytecode, being interpreted by the EVM the same way as constant
s. This change removes the need for the SLOAD
instruction when reading the variable and will save 2100 gas when variable is cold and 100 when it's warm.
File: canto-pfp-protocol/src/ProfilePicture.sol 35: string public subprotocolName;
#0 - c4-judge
2023-04-11T04:22:24Z
0xleastwood marked the issue as grade-b