Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

`Soulmate::totalSouls` does not return the proper amount of souls

Summary

Soulmate::totalSouls does not return the proper amount of souls

Vulnerability Details

Soulmate::totalSouls is a function that is aimed to return the number of Souls currently in the contract.

function totalSouls() external view returns (uint256) {
return nextID * 2;
}

However, it does not count people who still have not found it soulmate, and therefore, returning a number 1 unit lower than expected in some situations

Impact

Can result in a misscalculation if the result of the function is used in some arithmetic.

Tools Used

Foundry

Proof of Concept:
1-There is only a couple in the contract now, but soulmate3 calls Soulmate::mintSoulmateToken when nobody is looking for a soul
2- Soulmate::totalSouls returns 2, even though there are 3 souls on the contract

Code

Place the following code into Soulmate.t.sol

function testReturnsTotalSoulsProperly() public {
address soulmate1 = makeAddr("soulmate1");
address soulmate2 = makeAddr("soulmate2");
address soulmate3 = makeAddr("soulmate3");
vm.prank(soulmate1);
soulmateContract.mintSoulmateToken();
vm.prank(soulmate2);
soulmateContract.mintSoulmateToken();
vm.prank(soulmate3);
soulmateContract.mintSoulmateToken();
//Prints 2, should print 3
console2.log(soulmateContract.totalSouls());
}

Recommendations

Actually having a variable that counts the number of people that call Soulmate::mintSoulmateToken without reverting.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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