pragma solidity ^0.8.2;
import "@openzeppelin/contracts@4.4.2/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts@4.4.2/access/Ownable.sol";
import "@openzeppelin/contracts@4.4.2/token/ERC1155/extensions/ERC1155Supply.sol";
/// @custom:security-contact
contract Punks is ERC1155, Ownable, ERC1155Supply {
uint256 public price = 1 ether;
uint256 public totalsup = 10;
uint256 public percoin = 2;
constructor()
ERC1155("https://opensea-creatures-api.herokuapp.com/api/creature/{id}")
{}
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
function mint(address account, uint256 id, uint256 amount, bytes memory data)
public
payable
{
if(msg.sender != owner()){
uint256 mintCount = totalSupply();
require(totalsup > 0);
require(amount <= percoin);
require(mintCount + amount >= mintCount);
require(msg.value >= price * amount);
}
_mint(account, id, amount, data);
}
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
public
onlyOwner
{
_mintBatch(to, ids, amounts, data);
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
internal
override(ERC1155, ERC1155Supply)
{
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
}
I've been trying for 14 hours straight to create and test my first contract. Looking at the distance I've traveled and the time I've spent, I'm laughing at myself. There are few resources and they are not in my native language, I could not find a clear example of method usage.
uint256 mintCount = totalSupply();