Difficulty verifying with Hardhat on Windows PowerShell

Hi @Skyge, First of all, thank you for your infinite patience with everyone, and I hope it doesn't bother you too much.

Well, I have listened to you and I have tried to verify a contract through hardhat.
I'm happy because this time at least it gives me another error.
Something more clearer.

The constructor for contracts/FishervsPirate.sol:FishervsPirate has 3 parameters
but 1 arguments were provided instead.     

I have used the following instruction but it is not clear to me if at the end of it the number of arguments has to be specified or not. I have tried with your number and also without putting anything

npx hardhat  verify --network testnet 0x11743D5D71E55A65c2c7760F5536DdE7339be543 

I have googled a bit and it is suggested to add in the abi bytecode of the contract arguments.
I have gone to the next pagehttps://abi.hashex.org/ and I created the bytecode:

000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000e46697368657276735069726174650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003467650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096e6f426173655552490000000000000000000000000000000000000000000000

Now, it is not commented in which part of the abi it is necessary to place this.

It is true that this time I have not separated the Openzeppellin files and have thus compiled the contract

//SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";

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

// File: contracts/FishervsPirate.sol

contract FishervsPirate is ERC721Enumerable, Ownable  

{   

    

    string public baseURI;

    mapping(uint256 => string) private _tokenURIs;

    mapping(address => bool) private  _minters;

        

    bool public saleIsActive = false;

    uint256 public _tokenPrice = 100000000000000000; //0.1 BNB

    

      /**

   * Event for token purchase logging

   * @param purchaser who paid for the tokens

   * @param beneficiary who got the tokens

   * @param value weis paid for purchase

   * @param idToken NFT purchased

   */

  event TokenPurchase(

    address indexed purchaser,

    address indexed beneficiary,

    uint256 value,

    uint256 idToken

  );

  

   /**

   * Event for token purchase logging

   * @param minter who minted tokens

   * @param numberOfTokens number of tokens minted

   */

  event MultipleMint(

    address indexed minter,

    uint256 numberOfTokens,

    uint256 supply

  );

  

   /**

   * Event for token purchase logging

   * @param amount total sale balance

   * @param date collection date

   */

  event WithdrawTime(

    uint256 amount,

    uint256 date

  );

    

    constructor(string memory name, string memory symbol, string memory baseUri) 

    ERC721(name, symbol) 

    {

        setBaseURI(baseUri);

        _minters[msg.sender] = true;

    }

         /**

     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each

     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty

     * by default, can be overriden in child contracts.

     */

    function _baseURI() internal view virtual override returns (string memory) 

    {

        return baseURI;

    }

    function withdraw() public onlyOwner 

    {

        uint256 amount = address(this).balance;

        payable(msg.sender).transfer(amount);

        flipSaleState();

        emit WithdrawTime(amount, block.timestamp);

        

    }

    

    function saleMintToken(address buyer) public payable 

    {

    require(saleIsActive, "Salemint must be active to buy Tokens");

    require(msg.value >= _tokenPrice, "value sent needs to be atleast sale price");

    

        uint256 supply = totalSupply();

        _safeMint(buyer, supply + 1);

        emit TokenPurchase(owner(), buyer, msg.value, supply + 1);

     

    }

    

     function mintToken(uint256 tokensNumber) public  

     {

        require(_minters[msg.sender], "You don't are allowed for minting");

        uint256 supply = totalSupply();

        for (uint256 i = 0; i < tokensNumber; i++) {

            _safeMint(owner(), supply + 1);

            supply++;

        }

        

        emit MultipleMint(msg.sender, tokensNumber, supply);

    }

           /**

         * @dev approve an account for mint

         */

         function setMinterApproved(address minter) public onlyOwner 

    {   require(!_minters[minter], "address minter allowed for minting");

        _minters[minter] = true;

    }

    

        /**

         * @dev disapprove an account for mint

         */

         function setMinterDisapproved(address minter) public onlyOwner 

    {

         require(_minters[minter], "address minter not allowed for minting");

        _minters[minter] = false;

    }

    

      /**

     * @dev show all the tokens of the owner.

     */

    function tokensOfOwner(address owner) public view returns (uint256[] memory)

    {

        uint256 ownerTokenCount = balanceOf(owner);

        uint256[] memory tokenIds = new uint256[](ownerTokenCount);

        for (uint256 i; i < ownerTokenCount; i++) {

            tokenIds[i] = tokenOfOwnerByIndex(owner, i);

        }

        return tokenIds;

    }

    function setBaseURI(string memory newBaseURI) public onlyOwner 

    {

        baseURI = newBaseURI;

    }

    

     function setTokenPrice(uint256 tokenPrice) public onlyOwner 

    {

        _tokenPrice = tokenPrice;

    }

    function getBalance() public view onlyOwner returns(uint256)  

    {

        return address(this).balance;

    }

    

    /**

     * @dev See {IERC721Metadata-tokenURI}.

     */

    function tokenURI(uint256 tokenId) public view override returns (string memory) 

    {

        require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];

        string memory base = _baseURI();

        // If there is no base URI, return the token URI.

        if (bytes(base).length == 0) {

            return _tokenURI;

        }

        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).

        if (bytes(_tokenURI).length > 0) {

            return string(abi.encodePacked(base, _tokenURI));

        }

        return super.tokenURI(tokenId);

    }

    /**

     * @dev Sets `tokenURI` as the tokenURI of `tokenId`.

     *

     * Requirements:

     *

     * - `tokenId` must exist.

     */

    function _setTokenURI(uint256 _tokenId, string memory _tokenURI) public onlyOwner

    {

        require(_exists(_tokenId), "ERC721URIStorage: URI set of nonexistent token");

        _tokenURIs[_tokenId] = _tokenURI;

    }

    

      /*

    * Pause sale if active, make active if paused

    */

    function flipSaleState() public onlyOwner 

    {

        saleIsActive = !saleIsActive;

    }

    

}

deployed in testnet: 0x11743D5D71E55A65c2c7760F5536DdE7339be543

Where do I have to specify the contract arguments if that is the error?

If you has three parameters, I think it can be

npx hardhat  verify --network testnet 0x11743D5D71E55A65c2c7760F5536DdE7339be543 "parameters1" "parameters2" "parameters3"

Yes!! I new problem!! This is great!!

We have already learned to parameterize the arguments.

However, a new error is returned to me.

I don't know if it will be a version problem. I think I have the last one installed.
"@nomiclabs/hardhat-etherscan": "^2.1.6"
Or should I try separate files?

Emmm, maybe you can have a try to use the latest version.

And I just give an example for your case, you should change it for your contract. That is

npx hardhat  verify --network testnet 0x11743D5D71E55A65c2c7760F5536DdE7339be543 "YOUR_CONTRACT_NAME" "YOUR_CONTRACT_SYMBOL" "YOUR_CONTRACT_URI"

it should be your actual parameter value rather than my example parameter value, so have I made myself clear?

Yes, you speak very clearly. I try to follow his instructions to the letter.

The version I have is latest:

It makes sense to place the values โ€‹โ€‹of the parameters. Sorry. Still the same error is returned:

As always thank you very much for your time.

@Skyge
I again .. sorry

I have detached the files to check if that was the verification error ... I cleaned artifacts folder.
para_mandar

I have compiled and deployed perfectly ...

And I have placed my arguments the same as in my deployed. Keep giving me error.

My deploy js:

  // We get the contract to deploy
  const FishervsPirate = await hre.ethers.getContractFactory("FishervsPirate");
  const fishervsPirate = await FishervsPirate.deploy("FishervsPirate", "FvP", "noBaseURI/"); 

@Cainuriel There is something weird in your output:

Notice how the URI argument is written as "noBaseURI\". Someone along the way may be switching your forward slash to a backward slash. I don't know if this is the shell itself, Node, npm, or Hardhat.

You can try verifying a deployment using no slashes in the argument. But then you will need ot figure out where the slash is being changed and how to get it to stay a forward slash.

This is clearly related to running the command on a Windows shell. Personally I would strongly recommend using a more Unix-like shell.

Oh Thank you @frangio very much for your good eye. That was precisely the problem.

I have updated the main message to verify that I entered / instead of \. Something must be about the windows powershell.

Since the baseUri will be updated later, I have deployed it without using slash. And the verification has been a success !! Thank you.

2 Likes

The problem persists using git bash on windows. I thought that being a linux structure it would work. But it has not been that way.

You can define arguments in a JavaScript file as explained in the section Complex arguments of the documentation for the plugin.

Alternatively, verify using JavaScript entirely.

I would expect either of these approaches to fix your problem.

This is the solution. Thank you so much.