Hey guys I'm trying to display my ERC1155 collection in the open sea and i have few issues. My NFT's are deployed on ipfs but i really having issue setting uri in the constructor and then when i'm creating a token what need to be passed, generated hash from ipfs Qmf9SLxepjjeEoDJLVnL3GE74Q96Zpgh2Xq4zL7iKPqgZY or his CID bafybeihzw5hohe3mdjldvt34wvbfqybkau5beeebvds4hy6ewguox3j4hm really confused on these things

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract Launchpad is ERC1155 {
    using Counters for Counters.Counter;
    Counters.Counter private ID;

    // Mapping from token ID to token URI
    mapping(uint256 => string) private idToUri;

    // Mapping from token ID to token supply
    mapping(uint256 => uint256) private tokenSupply;

    constructor(string memory _uri) ERC1155(_uri) {}

    function create(string calldata _cid, bytes calldata _data)
        returns (uint256 _id)
        _id = _nextId();

        _mint(msg.sender, _id, 0, _data);

        string memory _uri = _createUri(_cid);
        idToUri[_id] = _uri;

        emit URI(_uri, _id);

    function mint(
        address _account,
        uint256 _id,
        bytes calldata _data
    ) public {
        require(_exists(_id), "Err: Invalid ID");

        _mint(_account, _id, 1, _data);


    function _nextId() internal returns (uint256 id) {
        return ID.current();

    function _exists(uint256 _id) internal view returns (bool) {
        return (bytes(idToUri[_id]).length > 0);

    function _createUri(string memory _cid)
        returns (string memory _uri)
        string memory baseUri = super.uri(0);
        return string(abi.encodePacked(baseUri, _cid));

    function uri(uint256 _id) public view override returns (string memory) {
        return idToUri[_id];


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.