Skip to content

two things #43

@artman325

Description

@artman325

it's easy to add these conditions

  1. don't exceed maxTotalSupply
  2. make a method buy() which will transferFrom(msg.sender, token, amount) and mint-send ITR or revert if exceeding maxTotalSupply
function buy(amount) {

if (buyPrice == 0) {
   revert BuyNotAvailable();
}
if (buyToken == address(0)) {
   _mint(msg.sender, msg.value / buyPrice); // ignore amount
} else {
   IERC20(buyToken).transferFrom(msg.sender, amount);
   _mint(msg.sender, amount / buyPrice);
}

};
function _mint() {
   if (maxTotalSupply > 0 && totalSupply > maxTotalSupply) {
        revert MaxTotalSupplyExceeded();
   }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions