0

When I create an OpenZeppelin ERC721 Smart Contract using OpenZeppelins Smart Contract wizard builder, I get an error when trying to deploy the smart contract to my local network using hardhat. I have tried updating all the modules to the newest version, but still I can't get a basic smart contract working.

Error message:

C:\Users\ericb\Desktop\vue-project>npx hardhat run scripts/deploy.js --network localhost
Compiled 2 Solidity files successfully (evm target: paris).
TypeError: unsupported addressable value (argument="target", value={  }, code=INVALID_ARGUMENT, version=6.8.1)
    at makeError (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\utils\errors.ts:687:21)
    at assert (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\utils\errors.ts:715:25)
    at assertArgument (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\utils\errors.ts:727:5)
    at resolveAddress (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\address\checks.ts:122:19)
    at C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\contract\contract.ts:172:60
    at ParamType.#walkAsync (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\abi\fragments.ts:777:24)
    at ParamType.walkAsync (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\abi\fragments.ts:795:24)
    at C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\contract\contract.ts:170:22
    at Array.map (<anonymous>)
    at resolveArgs (C:\Users\ericb\Desktop\vue-project\node_modules\ethers\src.ts\contract\contract.ts:169:37) {
  code: 'INVALID_ARGUMENT',
  argument: 'target',
  value: {},
  shortMessage: 'unsupported addressable value'
}

Steps to reproduce:

  1. Create a vue project npm create vue@latest. Select all default values.
  2. Set up hardhat in the newly created project and select all default values:
cd vue-project
npm install --save-dev hardhat @openzeppelin/contracts @nomicfoundation/hardhat-toolbox
npx hardhat
  1. Change the solidity version in hardhat.config.js to 0.8.20.
  2. Replace the code in contracts/Lock.sol with the code from the OpenZeppelin contract wizard when Mintable is selected from the left menu:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC721, Ownable {
    constructor(address initialOwner)
        ERC721("MyToken", "MTK")
        Ownable(initialOwner)
    {}

    function safeMint(address to, uint256 tokenId) public onlyOwner {
        _safeMint(to, tokenId);
    }
}

  1. Replace scripts/deploy.js with:
const hre = require("hardhat");

async function main() {
  const lock = await hre.ethers.deployContract("MyToken", []);
  await lock.waitForDeployment();
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

  1. Run npx hardhat node in one console and npx hardhat run scripts/deploy.js --network localhost in the other.
  2. Smart Contract is expected to be deployed at this point, but instead I get the error message initially provided.

How do I fix this? Or at the very least, how do I better understand the origin of this error? It seems like it doesn't even come from any code that I have written. For example; I haven't used the argument target anywhere that I can see, so how do I understand this error messsage?

npm installs these versions:

+-- @nomicfoundation/[email protected]
+-- @openzeppelin/[email protected]
+-- @vitejs/p[email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

I appreciate your time reading this.

0

Your Answer

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

Browse other questions tagged or ask your own question.