title: Hardhat issue UNPREDICTABLE_GAS_LIMIT in a script within ethereum development of ERC-721
body: <p>I have a problem that I really despair of and I think it has maybe to do with an &quot;wait for confirmation?&quot; issue, but I don't know how to activate this.</p>
  <p>Issue is, that I get as result of an request against a function of my ERC-721 contract following message in a <strong>deployment script</strong>:</p>
  <p>reason: 'cannot estimate gas; transaction may fail or may require manual gas limit',
  code: 'UNPREDICTABLE_GAS_LIMIT',</p>
  <p>I think it maybe has to do with that the commands are happening to fast after each other because, when I proceed the following steps in a hardhad console manually (npx hardhat console --network rinkeby), everthing works without this error (even with that &lt;&gt;.confirmations are always 0, what I don't understand)</p>
  <p>I have the following commands in a deploy.js
  I run with:</p>
  <p><strong>npx hardhat run --network rinkeby scripts/deploy.js</strong></p>
  <pre><code>async function main() {
      const BBA = await hre.ethers.getContractFactory(&quot;mycontract&quot;);
      const bba = await BBA.deploy();
      await bba.deployed();
      console.log(&quot;mycontract deployed to:&quot;, bba.address);
  
      await bba.safeMint(&quot;0x123...&quot;, 0, 'https://gateway.pinata.cloud/ipfs/url');
  
      await bba.lockToken(0, &quot;1644598343&quot;);
  
      console.log(await bba.getLock(0));
      ...
  }
  </code></pre>
  <p>With the call await bba.getLock(0) I get the
  <strong>Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={&quot;name&quot;:&quot;ProviderError&quot;,&quot;code&quot;:-32000,&quot;_isProviderError&quot;:true}, method=&quot;call&quot;, transaction= ...</strong></p>
  <p>I build a 1:1 ERC-721 based on openzeppelin contract wizard
  <a href="https://docs.openzeppelin.com/contracts/4.x/wizard" rel="nofollow noreferrer">https://docs.openzeppelin.com/contracts/4.x/wizard</a>.</p>
  <p>In this contract I added a simple function:</p>
  <pre><code>    mapping(uint256 =&gt; uint256) private _locks;
  
      function lockToken(
          uint256 targetTokenId,
          uint256 since,
      ) public {
          _locks[targetTokenId] = since;
      }
      
     function getLock(uint256 targetTokenId) public view returns (uint256) {
          return _locks[targetTokenId];
      }
  </code></pre>
  <p>I use INFURA with following hardhat.config.js:</p>
  <pre><code>const { projectId, mnemonic } = require('./secrets.json');
  
  module.exports = {
      rinkeby: {
        url: &quot;https://rinkeby.infura.io/v3/&quot; + projectId,
        accounts: { mnemonic: mnemonic },
        confirmations: 2,
        gas: 2100000,
        gasPrice: 8000000000,
        saveDeployments: true
      }
    },
    solidity: {
      version: &quot;0.8.4&quot;,
      settings: {
        evmVersion: &quot;byzantium&quot;,
        optimizer: {
          enabled: true,
          runs: 1500,
        }
      }
    }
  };
  </code></pre>
  <p>Anyone could guide me, to the reason of that problem?</p>
  <p>Thanks in advance.</p>