0

I am running code to mint an NFT, after the contract deploys, I am getting this error message but I dont really know what to take from it. Is there something specific that could tell me the reason I am getting this error message?

Command I am running:

npx hardhat run scripts/deploy.js --network goerli

Here is my deploy code:

const deployContract = async () => {
    const nftContractFactory = await hre.ethers.getContractFactory('JSNFT');
    const nftContract = await nftContractFactory.deploy({gasPrice: 8000000000});
    await nftContract.deployed();
    console.log("Contract deployed to:", nftContract.address);
    const aiImages = [
      '{ "name": "JS-NFT-AI-ART-2", "description": "AI art created by JS-NFT", "image": "https://www.dropbox.com/s/o5h5f9deg7nm5cj/AI-POST-WORLD-2.jpeg?raw=1" }',
      '{ "name": "JS-NFT-AI-ART", "description": "AI art created by JS-NFT", "image": "https://www.dropbox.com/s/toq98op6t8g9wts/AI-POST-WORD-1.jpeg?raw=1" }'
    ] 

    let itemID = 0
    while(itemID <= aiImages.length - 1) {
      await nftContract.setNFTData(itemID, aiImages[itemID])
      let txn = await nftContract.makeJSNFT()
      await txn.wait()
      await nftContract.tokenURI(itemID)
      itemID++;
    }
  };


const main = async () => {
    try {
      await deployContract();
      process.exit(0);
    } catch (error) {
      console.log(error);
      process.exit(1);
    }
  };
  
  main();

Error Message:

Contract deployed to: 0x2e95DE6abF74a45185c3541Ca1204c6f59B3ee13
Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b", transaction={"hash":"0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b","type":0,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x88e6Bc4Fcb2665b2c40a43510DfCB2aF9ea05305","gasPrice":{"type":"BigNumber","hex":"0x018148d4c3"},"gasLimit":{"type":"BigNumber","hex":"0x017a05"},"to":"0x2e95DE6abF74a45185c3541Ca1204c6f59B3ee13","value":{"type":"BigNumber","hex":"0x00"},"nonce":172,"data":"0xde9b9be0","r":"0x428a4c7918d5b8fa802759e6a84ce69ed733909483fd68ceb86324305eae763e","s":"0x2cca398ad98b5e2cca5f40c1d9e64f0b9de8dc057e0d0c57f11c4308abae5250","v":45,"creates":null,"chainId":5}, receipt={"to":"0x2e95DE6abF74a45185c3541Ca1204c6f59B3ee13","from":"0x88e6Bc4Fcb2665b2c40a43510DfCB2aF9ea05305","contractAddress":null,"transactionIndex":64,"gasUsed":{"type":"BigNumber","hex":"0x017a05"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x87094617d41420943b5876d4877c07b7ebfeaefab00fdb78ac8fd043943dbd5b","transactionHash":"0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b","logs":[],"blockNumber":7911764,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x01873edc"},"effectiveGasPrice":{"type":"BigNumber","hex":"0x018148d4c3"},"status":0,"type":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.7.1)
    at Logger.makeError (/Users/jasnelson/Desktop/the-side-projects/js-nft/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (/Users/jasnelson/Desktop/the-side-projects/js-nft/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at EthersProviderWrapper.<anonymous> (/Users/jasnelson/Desktop/the-side-projects/js-nft/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1549:24)
    at step (/Users/jasnelson/Desktop/the-side-projects/js-nft/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
    at Object.next (/Users/jasnelson/Desktop/the-side-projects/js-nft/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
    at fulfilled (/Users/jasnelson/Desktop/the-side-projects/js-nft/node_modules/@ethersproject/providers/lib/base-provider.js:20:58) {
  reason: 'transaction failed',
  code: 'CALL_EXCEPTION',
  transactionHash: '0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b',
  transaction: {
    hash: '0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b',
    type: 0,
    accessList: null,
    blockHash: null,
    blockNumber: null,
    transactionIndex: null,
    confirmations: 0,
    from: '0x88e6Bc4Fcb2665b2c40a43510DfCB2aF9ea05305',
    gasPrice: BigNumber { value: "6464001219" },
    gasLimit: BigNumber { value: "96773" },
    to: '0x2e95DE6abF74a45185c3541Ca1204c6f59B3ee13',
    value: BigNumber { value: "0" },
    nonce: 172,
    data: '0xde9b9be0',
    r: '0x428a4c7918d5b8fa802759e6a84ce69ed733909483fd68ceb86324305eae763e',
    s: '0x2cca398ad98b5e2cca5f40c1d9e64f0b9de8dc057e0d0c57f11c4308abae5250',
    v: 45,
    creates: null,
    chainId: 5,
    wait: [Function (anonymous)]
  },
  receipt: {
    to: '0x2e95DE6abF74a45185c3541Ca1204c6f59B3ee13',
    from: '0x88e6Bc4Fcb2665b2c40a43510DfCB2aF9ea05305',
    contractAddress: null,
    transactionIndex: 64,
    gasUsed: BigNumber { value: "96773" },
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    blockHash: '0x87094617d41420943b5876d4877c07b7ebfeaefab00fdb78ac8fd043943dbd5b',
    transactionHash: '0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b',
    logs: [],
    blockNumber: 7911764,
    confirmations: 1,
    cumulativeGasUsed: BigNumber { value: "25640668" },
    effectiveGasPrice: BigNumber { value: "6464001219" },
    status: 0,
    type: 0,
    byzantium: true
  }
}

1 Answer 1

0

It seems like the transaction ran out of gas. If you look up the hash of the transaction on etherscan, you'll see it.

enter image description here

https://goerli.etherscan.io/tx/0x63dfd6f931550ebffd459049ce04b68e759a8d2dcedf62e2eaa671deb30c998b

However, you can also see this in the response you received. The transaction's gas limit is 96773, and it used up all of it.

In transaction: gasLimit: BigNumber { value: "96773" },

In receipt: gasUsed: BigNumber { value: "96773" },

You need to increase the gasLimit for the calls of setNFTData(), makeJSNFT().

1
  • Thank you this worked for me, although i had to set it in the UI instead of the solidity code itself. But maybe it is better that way to have more control over it
    – JaySnel
    Nov 7, 2022 at 23:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.