Skip to content

Commit

Permalink
update contract doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Oct 30, 2024
1 parent 0f9b5bf commit a2bce55
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions solidity/src/MaybeMintERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/**
* @title MaybeMintERC721
* @dev Mint ERC721 tokens for a fee in ERC20 tokens
* @dev Mint ERC721 tokens for a fee in ERC20 tokens. As this simple token is intended for
* demonstration of batched EVM calls on Flow EVM using a single Cadence transaction, the
* minting process is random and has some chance of failure.
*/
contract MaybeMintERC721 is ERC721, Ownable {
IERC20 public denomination;
uint256 public mintCost;
address beneficiary;
address public beneficiary;
uint256 public totalSupply;

event MintCostUpdated(uint256 newCost);
Expand All @@ -33,28 +35,34 @@ contract MaybeMintERC721 is ERC721, Ownable {
}

/**
* @dev Mint a new ERC721 token to the caller. This contract must be approved to transfer mintCost amount from the caller
* before minting the ERC721 to pay for mint
* @dev Mint a new ERC721 token to the caller with some chance of failure. This is for
* demonstration purposes, intended to showcase how a single Cadence transaction can batch
* multiple EVM calls and condition final execution based on the result of any individual
* EVM call.
*
* NOTE: This contract address must be approved to transfer mintCost amount from the caller
* to the beneficiary before minting the ERC721 to pay for mint
*/
function mint() external {
// TODO: Get a random number to determine if the mint is successful
// TODO: Set token URI
totalSupply++; // increment the total supply
denomination.transferFrom(msg.sender, beneficiary, mintCost); // take payment for mint
_mint(msg.sender, totalSupply); // mint the token, assigning the next tokenId
}

/**
* @dev Set the cost to mint a new ERC721 token
* @param _mintCost The new cost to mint a token in the denomination ERC20 token
* @param _mintCost The new cost to mint a token in the denomination IERC20 token
*/
function setMintCost(uint256 _mintCost) external onlyOwner {
mintCost = _mintCost;
emit MintCostUpdated(_mintCost);
}

/**
* @dev Set the ERC20 token to use as the denomination
* @param _denomination The address of the ERC20 token to use as the denomination
* @dev Set the IERC20 contract to use as the denomination
* @param _denomination The IERC20 contract address to use as the denomination for mint fee
*/
function setDenomination(address _denomination) external onlyOwner {
require(_denomination != address(0), "Denomination cannot be the zero address");
Expand All @@ -64,7 +72,7 @@ contract MaybeMintERC721 is ERC721, Ownable {
}

/**
* @dev Set the address to receive the minting fees
* @dev Set the address to receive the IERC20 token paid for minting fees
* @param _beneficiary The address to receive the minting fees
*/
function setBeneficiary(address _beneficiary) external onlyOwner {
Expand Down

0 comments on commit a2bce55

Please sign in to comment.