1

I'm writing a Hardhat test for my contract.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
 
contract Nft is Initializable, ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable , PausableUpgradeable{
 using Counters for Counters.Counter;
  Counters.Counter private _tokenIds;

  address public admin;

  struct NftItem {
      uint256 id;
      address creator;
      string uri;
      bool isMarket;
  }
  mapping(uint256 => NftItem) public NftItems; 
  
  struct UserSell {
      uint256 nftCount;
      uint256 sellAmount;
  }
  mapping(address => UserSell) public UserSells; 

  mapping(address => uint256) public UserNftCount; 
  struct MarketItem {
          uint256 tokenId;
          address payable creator;
          address payable owner;
          uint256 price;
          uint256 startDate;
          uint256 endDate;
          bool ForSale;
          bool transfertoAdmin;
    }
  mapping(uint256 => MarketItem) public MarketItems;
  Counters.Counter private SellNftCount;

  struct SellItem {
          uint256 tokenId;
          address payable buyerAddress;
          uint256 price;
  }
  mapping(uint256 => SellItem[]) private SellItems;

  uint[] public BlackList;
  mapping(uint => bool) public BlackListExist;

  WETH eth;

  struct userOffer {
          uint256 tokenId;
  }
  mapping(address => userOffer[]) private UserOffers;

    // constructor () {
    //     _disableInitializers();
    // }

    function initialize(address _WETH) initializer public {
        __ERC721_init("ETH Collections", "ETHSTORE");
        __Ownable_init();
        __UUPSUpgradeable_init();
        __Pausable_init();
        eth= WETH(payable(_WETH));
        admin = msg.sender;

    }
    //...

My test code is:

     describe("Contract Version 1 test", function () {
    it("Should return the greeting after deployment", async function () {
      const Nft = await ethers.getContractFactory("Nft");
      nftContract = await upgrades.deployProxy(Nft, [weth.address], { initializer: 'initialize', kind: 'uups'});
      await nftContract.deployed();
  
      expect(1000).to.equal(1000);
    
    });
  });

I'm getting this error:

Error: invalid format type (argument="format", value=true, code=INVALID_ARGUMENT, version=abi/5.7.0)

at line `nftContract = await upgrades.deployProxy(Nft, [weth.address], { initializer: 'initialize', kind: 'uups'});`

Thank you for helping me!

5
  • You can try checking what the Nft contract's constructor accepts as an argument. It looks like it requires an argument "format" that you're not passing in, falsely trying to pass in the argument for the "initializer" function.
    – Mila A
    Commented Jul 7, 2023 at 9:01
  • Well, how can I solve the problem? i dont understand the problem
    – Mehran Ra
    Commented Jul 7, 2023 at 9:30
  • please share the full code of your contract so I can open it in Remix IDE and see
    – Mila A
    Commented Jul 7, 2023 at 9:58
  • What is your WETH struct?
    – Mila A
    Commented Jul 7, 2023 at 10:00
  • Weth is smart contract of wrapped ether and nothing else
    – Mehran Ra
    Commented Jul 7, 2023 at 19:15

0

Your Answer

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