The effect of missing an approve()
call in repayBadDebtWithCash()
function is that the transferFrom()
function will fail. This is because the transferFrom()
function relies on the allowance
set by the approve()
function to ensure that the transfer amount
is within the approved limit. Without an approve()
call, the contract does not have the necessary permissions to transfer tokens from the sender's address.
The missing approve()
call means that the contract does not have the permission to transfer the specified amount
of tokens from the sender's address. This results in the transferFrom()
function failing, as it checks the allowance
set by the approve()
function to ensure the transfer amount
is within the approved limit.
Due to this omission, the function cannot proceed with repaying bad debt as intended without the necessary approval.
Manual Review
In repayBadDebtWithCash()
function, before calling transferFrom()
, you should ensure that the sender
has approved the contract
to spend the amount
of tokens. This can be done by calling the approve()
function on the ERC20
token contract, specifying the contract's address as the spender and the amount to be approved
.
Here's how you could modify this to include the approve()
call:
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.