Skip to content

Viewing minted NFTS #196

Closed
Closed

Description

@silaslang

Hi all, firstly thank you for all the hard work you put in on this. I have a question that I'm not sure if is appropriate for here but I cant find the answers anywhere else. Its not an issue with the software.

I minted an NFT on gochain network but I cant work out how to view it as an image. What wallet will show the image I linked to via ipfs pinning at pinata?

Thanks

Activity

  1. jmank88 commented on Apr 5, 2021

    @jmank88
    Contributor

    Hi @silaslang

    Here is an example of an NFT with an image from our block explorer: https://explorer.gochain.io/token/0x29af464A1099Ddf11C5770d8E05CBa18cAeF47d4/asset/458574755479668142737315416416

    You can try viewing any GoChain NFT asset by plugging in you own token contract address and asset ID:
    https://explorer.gochain.io/token/<CONTRACT>/asset/<ID>

  2. silaslang commented on Apr 10, 2021

    @silaslang
    Author
  3. treeder commented on Apr 10, 2021

    @treeder
    Contributor

    Your token is here: https://explorer.gochain.io/token/0x7A5c15B8df397EF5aeDe2ef971f72838F663Ea51/asset/0

    Which looks like your contract is returning a metadata URL here: https://i.ibb.co/bNDvqdM/Qm-ZQr6d-YSNXdr-Lt-CMzj-Avip-UFHT7-Qygs-W5k-AP1-XFuj-Y7-W1.png0

    Which looks like a bad image URL, not a metadata URL.

    You should read this so you understand how they work: https://eips.ethereum.org/EIPS/eip-721

  4. cmatomic commented on Apr 10, 2021

    @cmatomic

    Look at this example: https://ipfs.io/ipfs/QmYP4SZMWLQ5ZcrkwTVK1v3NUK6fxvVDEHtTCyUAupg3jt
    2º example:
    web3 generate contract erc721 --symbol yourNFTsymbol --name "NFTNAME" --base-uri https://ipfs.io/ipfs/QmeP4vcyDQ9uzdRQNUcdfMgfvEGwbjixh2hSpkDNqBSHdZ?filename=nft.json

    *do not change this part ?filename=

  5. treeder commented on Apr 11, 2021

    @treeder
    Contributor

    I don't think that's right either, the base-uri should be https://ipfs.io/ipfs/ (or "ipfs://" if you expect your users to have something that can understand ipfs://).

    To use IPFS, it makes it quite a bit more complicated. You'll have to modify the contract web3 generates to use ERC721URIStorage and you can read more about why and how here. This should also have a new function like:

    function mint(address owner, string memory metadataURI)
        public
        returns (uint256)
        {
            _tokenIds.increment();
    
            uint256 id = _tokenIds.current();
            _safeMint(owner, id);
            _setTokenURI(id, metadataURI);
    
            return id;
        }
    

    Then to actually mint a token you have to do the following:

    • add image to ipfs and get image cid
    • create metadata json with name, description and image and in the image field, put: https://ipfs.io/ipfs/IMAGE_CID
    • add metadata json to ipfs and get metadata cid
    • Now you'd mint the token and pass in the cid
  6. cmatomic commented on Apr 12, 2021

    @cmatomic

    @treeder
    web3 generate contract erc721 --symbol yourNFTsymbol --name "NFTNAME" --base-uri https://ipfs.io/ipfs/QmeP4vcyDQ9uzdRQNUcdfMgfvEGwbjixh2hSpkDNqBSHdZ?filename=nft.json
    using this method obtained the following result .(the image may take a time to load )
    https://explorer.gochain.io/token/0x411Cc12dA82389a6d170A25e42212d1854fa4E4d/asset/0

    What did you mean by this "and pass in the cid" ?

  7. treeder commented on Apr 12, 2021

    @treeder
    Contributor

    To the mint function. You'd pass in https://ipfs.io/ipfs/{CID} for metadataURI.

    Anyways, looks like you got it working. Want to share what you did? Your contract code?

  8. cmatomic commented on Apr 12, 2021

    @cmatomic

    @treeder
    I did not change anything in the contract code, I simply copied the link from the IPFS Desktop application, this after several attempts to mint an NFT.
    But it is possible to use services such as pinata for that, just copy the CID and name of the .json file.
    https://ipfs.io/ipfs/{CID}?filename=nft.json

  9. silaslang commented on Apr 12, 2021

    @silaslang
    Author

    Thanks everyone for all the input and help. It appears I am getting somewhat closer to grasping this. I am new to all this but I am enjoying the learning. I couldn't grasp https://ipfs.io/ so I created the .json and pinned it at pinata .

    {

    "name": "Never Liked This Banksy",

    "description": "Silent Bill's streetart in reply to Banksys Never Liked The Beatles",
    "image": "https://gateway.pinata.cloud
    /ipfs/QmTqWkECDhFYL8mHXNkQvUjNzExouqMZLnpATaKMNYgEJV",

    }

    web3 generate contract erc721 --symbol SBFTW --name "Never Liked This Banksy" --base-uri https://gateway.pinata.cloud/ipfs/QmUxM3EZ7GdK6cxCyX8L8ajspnPCHJqn3FPnQAHYCZND9D?filename=banksy.json

    The sample contract has been successfully written to SBFTW.sol file

    web3 contract build SBFTW.sol

    NAME: SBFTW
    contractName: :EnumerableMap
    contractName: :ERC165
    contractName: :IERC721Enumerable
    contractName: :SBFTW
    contractName: :AccessControl
    contractName: :Context
    contractName: :ERC721
    contractName: :ERC721PresetMinterPauserAutoId
    contractName: :ERC721Burnable
    contractName: :Counters
    contractName: :Address
    contractName: :Strings
    contractName: :IERC165
    contractName: :IERC721Metadata
    contractName: :IERC721Receiver
    contractName: :SafeMath
    contractName: :EnumerableSet
    contractName: :IERC721
    contractName: :Pausable
    contractName: :ERC721Pausable
    Successfully compiled contracts and wrote the following files:
    Source file SBFTW_flatten.sol
    SBFTW.bin, SBFTW.abi

    web3 contract deploy SBFTW.bin
    Contract has been successfully deployed with transaction: 0xde3d02ff48be6d8eb1408dbe7fe816f891411522a2b3c5c654d70a59e79998a6
    Contract address is: 0x933f5c97a357B7574a2763249A1157D70Fed8b3d

    export WEB3_ADDRESS=0x933f5c97a357B7574a2763249A1157D70Fed8b3d

    web3 contract call --wait --abi SBFTW.abi --gas-limit 2000000 --function mint 0x03f42d46a09b922FD3D98CaC46B5B52F7a3cB98C
    Transaction hash: 0x42c8c7ef0fb21d923610a0d6791fd126baca8d00bd68857adb94033175963800
    Waiting for receipt...
    Transaction receipt address: 0x42c8c7ef0fb21d923610a0d6791fd126baca8d00bd68857adb94033175963800
    Block: #18354374 0xf16395bc1ef07ef6711fd822b408e3db0024aa22476a43f9fb3c4be7aaee71f8
    Tx Index: 0
    Tx Hash: 0x42c8c7ef0fb21d923610a0d6791fd126baca8d00bd68857adb94033175963800
    From: 0x56336272596E6dE04fD62D6A8a05821c0b0660F1
    To: 0x933f5c97a357B7574a2763249A1157D70Fed8b3d
    Gas Used: 158959
    Cumulative Gas Used: 158959
    Status: Successful
    Post State: 0x
    Bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000010000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000004000000000000000000000000000000000400000000000000102000000000000000080000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000000
    Logs: [0xc000033970]
    Parsed Logs: [
    {
    "name": "Transfer",
    "fields": {
    "from": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "to": "0x00000000000000000000000003f42d46a09b922fd3d98cac46b5b52f7a3cb98c",
    "tokenId": "0x0000000000000000000000000000000000000000000000000000000000000000"
    }
    }
    ]

    However, when viewed at Gochain Explorer I am getting this error:
    JSON.parse: expected double-quoted property name at line 9 column 1 of the JSON data

    I feel as if I am almost there , what do I need to fix? *

    EDIT, its the comma isnt it in this

    {

    "name": "Never Liked This Banksy",

    "description": "Silent Bill's streetart in reply to Banksys Never Liked The Beatles",
    "image": "https://gateway.pinata.cloud
    /ipfs/QmTqWkECDhFYL8mHXNkQvUjNzExouqMZLnpATaKMNYgEJV",

    }

  10. treeder commented on Apr 13, 2021

    @treeder
    Contributor

    yes, it's the comma.

    And again, you're doing it wrong. that base-uri won't allow you to have more than one NFT in your contract.

  11. silaslang commented on Apr 13, 2021

    @silaslang
    Author

    I'm so happy , I finally got it to work. Thank you for all the help. I appreciate your patience and assistance. It has been fun experimenting.

    https://explorer.gochain.io/token/0x521e5CFc5bF50f46d61375cB466f2B8a89d204b2/asset/0

    To mint more than 1 of these would do the following

    web3 contract call --wait --abi BANSKY.abi --gas-limit 2000000 --function mint 0x03f42d46a09b922FD3D98CaC46B5B52F7a3cB98C (INSERT THE AMOUNT TO MINT HERE?)

  12. treeder commented on Apr 13, 2021

    @treeder
    Contributor

    no, you can only mint 1 at a time.

  13. ranjithSts commented on Aug 30, 2022

    @ranjithSts

    hi @treeder your right need to update the contract mint function which is getting pulled using docker

  14. treeder commented on Aug 30, 2022

    @treeder
    Contributor

    @ranjithSts not sure what you mean, can you explain?

  15. ranjithSts commented on Sep 1, 2022

    @ranjithSts

    I don't think that's right either, the base-uri should be https://ipfs.io/ipfs/ (or "ipfs://" if you expect your users to have something that can understand ipfs://).

    To use IPFS, it makes it quite a bit more complicated. You'll have to modify the contract web3 generates to use ERC721URIStorage and you can read more about why and how here. This should also have a new function like:

    function mint(address owner, string memory metadataURI)
        public
        returns (uint256)
        {
            _tokenIds.increment();
    
            uint256 id = _tokenIds.current();
            _safeMint(owner, id);
            _setTokenURI(id, metadataURI);
    
            return id;
        }
    

    Then to actually mint a token you have to do the following:

    • add image to ipfs and get image cid
    • create metadata json with name, description and image and in the image field, put: https://ipfs.io/ipfs/IMAGE_CID
    • add metadata json to ipfs and get metadata cid
    • Now you'd mint the token and pass in the cid

    i mean this should be the actuall format but in the web3 gentrate contract erc721 when this is called in mint function the metadatauri is not getting passed or there is no variable as tokenuri in mint function

  16. ranjithSts commented on Sep 1, 2022

    @ranjithSts

    i think i have found a solution over here ... fix erc721 for latest openzeppelin changes (#182)

    // This allows the minter to update the tokenURI after it's been minted.
    // To disable this, delete this function.
    function setTokenURI(uint256 tokenId, string memory tokenURI) public onlyMinter {
    function setTokenURI(uint256 tokenId, string memory tokenURI) public {
        require(hasRole(MINTER_ROLE, _msgSender()), "web3 CLI: must have minter role to update tokenURI");
        _setTokenURI(tokenId, tokenURI);
    }
    

    }`

    i just need to know how to call this function , is this should be correct .. need an example of this

    web3 contract call --amount AMOUNT --address CONTRACT_ADDRESS --abi CONTRACT_ABI_FILE --function setTokenURI "tokenId" "tokenURI"

  17. treeder commented on Sep 1, 2022

    @treeder
    Contributor

    Looks right, you probably don't need the --amount flag though. Did you try it?

  18. locked and limited conversation to collaborators on Sep 1, 2022
  19. converted this issue into a discussion #271 on Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions