简体   繁体   中英

ERC1155 Creating NFT

pragma solidity ^0.8.0;


//import ERC1155 token contract from OpenZeppelin
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";

contract NFTXXX is ERC1155, Ownable {

    uint256 public constant Arcadiy = 0;
    uint256 public constant MAX = 1;

    constructor() ERC1155("http://ipfs.io/ipfs/{id}.json") {
        _mint(msg.sender, Arcadiy, 1, "");
        _mint(msg.sender, MAX, 2, "");
    }

    function mint(address account, uint256 id, uint256 amount) public onlyOwner {
        _mint(account, id, amount, "");
    }

    function burn(address account, uint256 id, uint256 amount) public {
        require(msg.sender == account);
        _burn(account, id, amount);

    }
}

Images do not appear on OpenSea(tes.net)

There are json files that i use for contract.

{
"image": "ipfs://bafybeienrrxym2d3b5u7glcvdrz63rztxkue7p4bly4fcsma55nupmxsvy", 
"description": "My first plant",
"name": "Cactus Arcadiy"

}

{
"image": "ipfs://bafybeieh4lcllyimopk6pmacjyx4atgdqsywvsia6nuuq6niucdqxwbq5i", 
"description": "GoodZone is a banya with pool",
"name": "Banya"

}

I think something is wrong with the referense for images ("http://ipfs.io/ipfs/{id}.json"), but i didn't find resolve.

Your image uri from the metadata is working though.

It seems that you treat the http://ipfs.io/ipfs/{id}.json as your NFT's Metadata storage place (actually it is NOT), which might cause error like TOKEN_0 (Arcadiy) would try to retrieve your metadata in http://ipfs.io/ipfs/0.json .

Therefore, you should replace it with your own storage address, ie, place your NFT Metadata to ipfs again and set the tokenURI to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM