40,000 USDC
View results
Submission Details
Severity: gas

returning address insted of IEscrow will save gas

Details

in the EscrowFactory contract newEscrow function returns the deployed address but it doesn't cast the returned value to address it returns IEscrow, But if you cast the IEscrow to type of address when you save it in memory variable and return it, it will save some gas here is an example

execution cost of this function is 154821

function newDeploy1(uint _price) external returns(Storage_1){
Storage_1 deployedStorage = new Storage_1{salt: 0}(_price);
return deployedStorage;
}

But execution of this function is 154621 (a bit smaller)

function newDeploy2(uint _price) external returns(address){
address deployedStorage = address(new Storage_1{salt: 0}(_price));
return deployedStorage;
}

You can test them in remix

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.