Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Missing assignment of a random Mondrian artwork to the newly created `MondrianWallet`

Summary

MondrianWallet currently lacks the functionality to mint NFTs to users who deploy their own instance of it, as per project specifications.

Vulnerability Details

MondrianWallet is intended to provide each user with a unique NFT featuring a Mondrian artwork upon creation of their wallet instance. However, the contract does not include functionality to mint these NFTs automatically.

Impact

Users expecting to receive a unique and randomly assigned NFT artwork might be disappointed or misled, which could harm the project's reputation and user trust.

Tools Used

Manual review

Recommendations

To address these issues effectively, MondrianWallet should implement token minting on wallet creation, with a truly randomized tokenId, which could be supplied via the Chainlink VRF.

Here's the recommended steps:

  • Calculate the address of the new MondrianWallet before deploying it

  • Create a Chainlink VRF subscription and fund it with LINK tokens

  • Add the following code to the MondrianWallet.sol:

+import "@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.sol";
+import "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
-contract MondrianWallet is Ownable, ERC721, IAccount {
+contract MondrianWallet is Ownable, ERC721, IAccount, VRFConsumerBaseV2 {
// ...
/*//////////////////////////////////////////////////////////////
STATE VARIABLES
//////////////////////////////////////////////////////////////*/
IEntryPoint private immutable i_entryPoint;
+ uint256 private immutable i_requestId;
- constructor(address entryPoint)
+ constructor(address entryPoint, address vrfCoordinator, bytes32 keyHash)
Ownable(msg.sender)
ERC721("MondrianWallet", "MW")
+ VRFConsumerBaseV2(vrfCoordinator)
{
i_entryPoint = IEntryPoint(entryPoint);
+ i_requestId = VRFCoordinatorV2Interface(vrfCoordinator).requestRandomWords(
+ keyHash,
+ subscriptionId, // TODO: Inject your subscription ID
+ 3, // requestConfirmations
+ 40000, // callbackGasLimit
+ 1 // numWords
+ );
}
+ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override {
+ require(i_requestId == requestId, "Invalid requestId");
+ uint256 tokenId = randomWords[0] % 4;
+ mint(tokenId);
+ }
// ...
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

The Wallet doesn't end up owning any nft

Support

FAQs

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