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

Reverts when trying to mint a horse

Summary

The contract reverts every time a horse is tried to be minted.

Vulnerability Details

_safeMint function calls the _checkOnERC721Received function when a token is to be minted. This function checks that the contract that receives the token implements ´´´onERC721Received´´´, which would allow it to keep the token. The HorseStore contract does not have this function so no token will be minted.

Impact

Critical as it does not allow to mint horses. Therefore, it should not allow to feed them or check if they are happy.

Tools Used

Foundry 'forge test':

´´´
abstract contract Base_Test is Test {
HorseStore horseStore;
address user = makeAddr("user");
string public constant NFT_NAME = "HorseStore";
string public constant NFT_SYMBOL = "HS";

function setUp() public virtual {
    horseStore = new HorseStore();
}

function testMint() public{
    horseStore.mintHorse();
}´´´

Received error:

HorseStoreSolidity::onERC721Received(HorseStoreSolidity: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], 0x0000000000000000000000000000000000000000, 0, 0x)
│ │ └─ ← "EvmError: Revert"
│ └─ ← "ERC721InvalidReceiver(0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496)"
└─ ← "ERC721InvalidReceiver(0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496)"

Recommendations

Implementing this onERC721Received function:

´´´
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4) {
return this.onERC721Received.selector;
}
´´´

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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