Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error veryfing Contract #22

Open
Mnuralim opened this issue Jul 25, 2024 · 0 comments
Open

Error veryfing Contract #22

Mnuralim opened this issue Jul 25, 2024 · 0 comments

Comments

@Mnuralim
Copy link

error i try to verifing contract

Error veryfing Contract. Reason: ProviderError: eth_getStorageAt was disabled, since storage is encrypted. Check docs at https://swisstronik.gitbook.io/swisstronik-docs/ for more information
    at HttpProvider.request (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\hardhat\src\internal\core\providers\http.ts:96:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getStorageAt (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\@openzeppelin\upgrades-core\src\provider.ts:75:19)
    at async getStorageFallback (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\@openzeppelin\upgrades-core\src\eip-1967.ts:51:15)
    at async getImplementationAddress (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\@openzeppelin\upgrades-core\src\eip-1967.ts:21:19)
    at async isTransparentOrUUPSProxy (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\@openzeppelin\upgrades-core\src\eip-1967-type.ts:13:5)
    at async verify (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\@openzeppelin\hardhat-upgrades\src\verify-proxy.ts:108:7)
    at async OverriddenTaskDefinition._action (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\@openzeppelin\hardhat-upgrades\src\index.ts:186:12)
    at async Environment._runTaskDefinition (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\hardhat\src\internal\core\runtime-environment.ts:359:14)
    at async Environment.run (D:\airdrop\airdrop\swisstronik-deploy-private-nft\node_modules\hardhat\src\internal\core\runtime-environment.ts:192:14)

this is my code :

import { config, ethers, run } from 'hardhat'
import fs from 'fs'
import path from 'path'

async function main() {
  const Contract = await ethers.getContractFactory('TestNFT')

  console.log('Deploying NFT...')
  const contract = await Contract.deploy()

  await contract.waitForDeployment()
  const contractAddress = await contract.getAddress()

  console.log('NFT deployed to:', contractAddress)

  console.log('Pausing 5 seconds in order to verify Contract')
  await delay()
  console.log('Pause finished. Verifying Contract...')

  try {
    await run('verify:verify', {
      address: contractAddress,
      constructorArguments: [],
      contract: 'contracts/NFT.sol:TestNFT',
    })
    console.log(
      'Contract verified to',
      config.etherscan.customChains[0].urls.browserURL + '/address/' + contract.target
    )
  } catch (error: any) {
    console.error('Error veryfing Contract. Reason:', error)
  }

  const deployedAddressPath = path.join(__dirname, '..', 'utils', 'deployed-address.ts')
  const fileContent = `const deployedAddress = '${contractAddress}'\n\nexport default deployedAddress\n`
  fs.writeFileSync(deployedAddressPath, fileContent, { encoding: 'utf8' })
  console.log('Address written to deployed-address.ts')
}

function delay() {
  return new Promise((resolve) => setTimeout(resolve, 5 * 1000))
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })

and this is my solidity code :

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

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

contract TestNFT is ERC721 {
    uint256 private _currentTokenId = 0;

    event NFTMinted(address recipient, uint256 tokenId);
    event NFTBurned(uint256 tokenId);

    constructor() ERC721("IzzyNFT", "IZZNFT") {}

    function mintNFT(address recipient) public returns (uint256) {
        _currentTokenId += 1;
        uint256 newItemId = _currentTokenId;
        _mint(recipient, newItemId);
        
        emit NFTMinted(recipient, newItemId);  

        return newItemId;
    }

    function burnNFT(uint256 tokenId) public {
        _burn(tokenId);
        emit NFTBurned(tokenId);  
    }

    function balanceOf(address account) public view override returns (uint256) {
        require(msg.sender == account, "Error: msg.sender != account");
        return super.balanceOf(account);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant