2

I'm trying to deploy Uniswap v3 locally. I launched a local node with a main net fork using Alchemy like this:

npx hardhat node --fork https://eth-mainnet.g.alchemy.com/v2/{API KEY}

My code is as simple as that:

const mainnetFactoryAddress = "0x1F98431c8aD98523631AE4a59f267346ea31F984"
const FactoryDeployedContract = await hre.ethers.getContractAt("UniswapV3Factory", mainnetFactoryAddress);

And this is the error output I'm getting:

HardhatError: HH700: Artifact for contract "UniswapV3Factory" not found. 
    at Artifacts._handleWrongArtifactForContractName (UniV3-test-hardhat/node_modules/hardhat/src/internal/artifacts.ts:678:11)
    at Artifacts._getArtifactPathFromFiles (UniV3-test-hardhat/node_modules/hardhat/src/internal/artifacts.ts:803:19)
    at Artifacts._getArtifactPath (UniV3-test-hardhat/node_modules/hardhat/src/internal/artifacts.ts:483:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Artifacts.readArtifact (UniV3-test-hardhat/node_modules/hardhat/src/internal/artifacts.ts:71:26)
    at getContractAt (UniV3-test-hardhat/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:314:22)
    at main (UniV3-test-hardhat/scripts/deploy.js:57:35)

I'm having trouble figuring out why it can't seem to find the artificat for the factory contract. Anyone would have an hint or a solution for this problem please?

Edit: I also installed the npm @uniswap/v3-core package and also have this line at the top: const UniswapV3Factory = require('@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json');

1 Answer 1

1

You can fix this using any one of the following ways:

  1. Install the npm package @uniswap/v3-core and import the factory bytecode located at @uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json

For example:

import {
  abi as FACTORY_ABI,
  bytecode as FACTORY_BYTECODE,
} from '@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json'

// deploy the bytecode
  1. Import UniswapV3Factory interface from the npm package to any of your smart contracts and compile using hardhat

For example:

import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

contract MyContract {
    // Your contract code 
}
  1. Copy the contract source code manually to your hardhat project and compile. Hardhat will generate contract Artifacts for you in the same project repo

For more details, check Uniswap V3 Github repo

2
  • Forgot to mention that I have this packaged installed already, and used it to import the necessary json. Btw how would I be able to deploy the contract just with the bytecode please?
    – VDS-Atomic
    Sep 15, 2022 at 12:18
  • You can deploy a contract just with the bytecode using eth_sendTransaction call. The data field would be your contract bytecode(appended by constructor arguments if any). For more details, check here: ethereum.org/en/developers/docs/apis/json-rpc/…
    – Sudeep
    Sep 15, 2022 at 18:14

Your Answer

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

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