If checks are added to the beginning of the newEscrow()
function that determine if the address of seller is ok and if the ‘arbiterFee’ is smaller than the price
, once can save 94918 gas if the input does not meet the criteria.
If the seller address is address(0)
or the ‘arbiterFee’ is smaller than the price
, calling newEscrow()
in EscrowFactory.sol
only fails after computing the destination address and sending tokens to it. This cost around 94918 gas. If the checks for seller
, arbiterFee
and price
were moved to the beginning of the function newEscrow()
this 94918 gas can be saved if the inputs don’t match the criteria.
To ensure the inputs are not checked twice, the checks for seller
, arbiterFee
and price
should be removed from the constructor of Escrow.sol
and a comment should be added that the contract is only to be deployed by EscrowFactory.sol
. If done so, also the check that the seller is not address(0)
can be removed since it is set to msg.sender
by the EscrowFactory
.
94918 gas is wasted if one of the inputs for seller
, arbiterFee
and price
do not match the criteria
Foundry
Move the following checks from the constructor of Escrow.sol
to the beginning of the newEscrow()
function in EscrowFactory.sol
:
Remove the following check from the constructor of Escrow.sol
:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.