Solidity

這個錯誤程式碼是什麼?

  • November 7, 2022

我正在執行程式碼來鑄造 NFT,在合約部署後,我收到此錯誤消息,但我真的不知道從中獲取什麼。有什麼具體的東西可以告訴我收到此錯誤消息的原因嗎?

我正在執行的命令:

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

這是我的部署程式碼:

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();

錯誤資訊:

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
 }
}

看來交易的gas用完了。如果您在 etherscan 上查找交易的雜湊值,您會看到它。

在此處輸入圖像描述

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

但是,您也可以在收到的回復中看到這一點。交易的gas limit是96773,並且已經用完了。

在交易中gasLimit: BigNumber { value: "96773" },

收據gasUsed: BigNumber { value: "96773" },

您需要增加,gasLimit的呼叫。setNFTData()``makeJSNFT()

引用自:https://ethereum.stackexchange.com/questions/138985