0

I am using the following code of NFT

// contracts/MyNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
// pragma solidity ^0.7.1;

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

contract MyNFT is ERC721 {
     using Counters for Counters.Counter;
     Counters.Counter private _tokenIds;
     constructor() ERC721("MyNFT", "MNFT") {}

     function mintNFT(string memory tokenURI) public returns (uint256) {
       _tokenIds.increment();
       uint256 newItemId = _tokenIds.current();
       _safeMint(msg.sender, newItemId);
       _setTokenURI(newItemId, tokenURI);
       return newItemId;
   }
}

When I call MinftNFT it returns:

truffle(develop)> myNFT.mintNFT("https://someurl.com/another_digital_asset.json", {from: accounts[3]})
{
  tx: '0x76f8a571d4a017606806c05ea805530e1191fcc4b565d6b657ebb4ba210e51d1',
  receipt: {
    transactionHash: '0x76f8a571d4a017606806c05ea805530e1191fcc4b565d6b657ebb4ba210e51d1',
    transactionIndex: 0,
    blockHash: '0xea5c7e614ed09e1e847a1dadcedaa238b233bc9e49e3d48e4432a5d211ab71f3',
    blockNumber: 4,
    from: '0x0ffa135d2dfb73b6488e3b1a7468a7100e38ba64',
    to: '0xdf3bf412a760f22d92155b4d58d38b75722b6329',
    gasUsed: 22152,
    cumulativeGasUsed: 22152,
    contractAddress: null,
    logs: [],
    status: true,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    rawLogs: []
  },
  logs: []
}

but when I call MyNFT.ownerOf(1) it returns:

ruffle(develop)> myNFT.ownerOf(1)
Uncaught:
Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at evalmachine.<anonymous>
    at sigintHandlersWrap (node:vm:271:12)
    at Script.runInContext (node:vm:139:14)
    at runScript (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:270:1)
    at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:285:1)
    at bound (node:domain:416:15)
    at REPLServer.runBound [as eval] (node:domain:427:12)
    at REPLServer.onLine (node:repl:846:10)
    at REPLServer.emit (node:events:365:28)
    at REPLServer.emit (node:domain:470:12)
    at REPLServer.Interface._onLine (node:readline:443:10)
    at REPLServer.Interface._line (node:readline:788:8)
    at REPLServer.Interface._ttyWrite (node:readline:1133:14)
    at REPLServer.self._ttyWrite (node:repl:941:9) {
  hijackedStack: "Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.\n" +
    '    at ABICoder.decodeParametersWith (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/lib/index.js:298:1)\n' +
    '    at ABICoder.decodeParameters (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/lib/index.js:285:1)\n' +
    '    at Contract._decodeMethodReturn (/usr/local/lib/node_modules/truf

I do not know why is it happening. MinfNFT transaction is not appearing in Ganache GUI either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.