Answers for "erc 1155 mint id dinamically"

1

erc 1155 mint id dinamically

contract MyERC1155 is ERC1155, Ownable {
    constructor() ERC1155("") {}

	uint256 public last_id = 0;
    
    function setURI(string memory newuri) public onlyOwner {
        _setURI(newuri);
    }

    function mint(address account, uint256 amount, bytes memory data)
        public
        onlyOwner
    {
        if(last_id > 0)
        {
            // incrementando quando necessário
            last_id++;
            // mintando
            _mint(account, last_id, amount, data);
        }
        else
        {
            // mintando
            _mint(account, last_id, amount, data);
            // incrementando quando necessário
            last_id++;
        }
    }
}
Posted by: Guest on February-07-2022

Browse Popular Code Answers by Language