How to use totalSupply

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;

    function setURI(string memory newuri) public onlyOwner {

    function mint(address account, uint256 id, uint256 amount, bytes memory data)
        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)
        _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)
        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();

Hi, welcome to the community! :wave:

I think for the function totalSupply() in the ERC1155, it needs a parameter for this function.
And maybe you can have a look at this documentation: ERC1155Supply | OpenZeppelin Docs

1 Like