0

I am currently working on deploying a contract in my local hardhat network, the files below:

  1. MockV3Aggregator.sol - the smart contract
    pragma solidity ^0.6.0;
    
    import "@chainink/contracts/src/v0.6/tests/MockAggregator.sol"
  1. The 00-deploy-mocks.js --- the file responsible for deploying the smart contract
  const {
      developmentChain,
      DECIMALS,
      INITIAL_ANSWER,
  } = require("../helper-hardhat.config")
  
  module.exports = async ({ getNamedAccounts, deployments }) => {
      const { deploy, log } = deployments
      const { deployer } = await getNamedAccounts()
  
      if (developmentChain.includes(network.name)) {
          log("Local Network detected! Deploying mocks... ")
          await deploy("MockV3Aggregator ", {
              contract: "MockV3Aggregator",
              from: deployer,
              log: true,
              args: [DECIMALS, INITIAL_ANSWER],
          })
          log("Mocks Deployed...")
          log("_________________________________________")
      }
  }

and my hardhat-config.js

 require("hardhat-deploy")
 
 /** @type import('hardhat/config').HardhatUserConfig */
 module.exports = {
     // solidity: "0.8.8",
     solidity: {
         compilers: [{ version: "0.8.8" }, { version: "0.6.0" }],
     },
     networks: {
         sepolia: {
             url: process.env.SEPOLIA_RPC_URL || "",
             accounts: [],
         },
     },
     gasReporter: {
         enabled: process.env.REPORT_GAS != undefined,
         currency: "USD",
     },
     etherscan: {
         apiKey: process.env.ETHERSCAN_API_KEY,
     },
     namedAccounts: {
         deployer: {
             default: 0,
         },
     },
 }

It keep giving this error in my terminal when i run the code below in my terminal:

Nothing to compile
Local Network detected! Deploying mocks... 
An unexpected error occurred:

Error: ERROR processing /Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/deploy/00-deploy-mocks.js:
Error: cannot find artifact "MockV3Aggregator"
    at getArtifact (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/DeploymentsManager.ts:207:17)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at getArtifactFromOptions (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/helpers.ts:502:20)
    at getLinkedArtifact (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/helpers.ts:518:38)
    at _deploy (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/helpers.ts:539:54)
    at _deployOne (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/helpers.ts:1014:16)
    at Object.module.exports [as func] (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/deploy/00-deploy-mocks.js:14:9)
    at DeploymentsManager.executeDeployScripts (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1222:22)
    at DeploymentsManager.runDeploy (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1055:5)
    at SimpleTaskDefinition.action (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/index.ts:438:5)
    at DeploymentsManager.executeDeployScripts (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1225:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at DeploymentsManager.runDeploy (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1055:5)
    at SimpleTaskDefinition.action (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/index.ts:438:5)
    at Environment._runTaskDefinition (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at Environment.run (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at SimpleTaskDefinition.action (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/index.ts:584:32)
    at Environment._runTaskDefinition (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at Environment.run (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at SimpleTaskDefinition.action (/Users/mac/Documents/Codes/blockchain-projects/Hardhat-FundMe/node_modules/hardhat-deploy/src/index.ts:669:5)

2 Answers 2

1

I belive this should fix your error...

use:

import "@chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol";
0

In the contracts\test\MockV3Aggregator.sol Make sure to have import "@chainlink/contracts/src/v0.8/tests/MockV3Aggregator.sol";

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.