# "Gas Estimation Failed" on mint function ERC-721 contract

**URL:** <https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072>\
**Category:** Contracts\
**Tags:** erc721\
**Created:** [January 3, 2022, 1:00am UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072 "2022-01-03T01:00:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brevital](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/brevital/32/11924_2.png) [@Brevital](https://forum.openzeppelin.com/u/Brevital)\
**Post date:** [January 3, 2022, 1:00am UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/1 "2022-01-03T01:00:03Z")

</div>

Deployed an NFT contract at:  
0x31ead4b531266d9e125f7b3223ecd7E7ECcbd94c

Was able to mint 1 NFT successfully but looks like I may have formatted the IPFS link wrong.  
The same contract deployed on Ropsten works well and mints without issues.

After minting once on mainnet, the second attempt gave a "Gas estimation failed" error

I'm sure I screwed up something basic here but can't figure out why it worked once & then started giving this error.

VERY basic contract:

#### 🔢 Code to reproduce

```auto
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
 
import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";
 
contract SenecaNFT is NFTokenMetadata, Ownable {
 
  constructor() {
    nftName = "SeNFT";
    nftSymbol = "SEN";
  }
 
  function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner {
    super._mint(_to, _tokenId);
    super._setTokenUri(_tokenId, _uri);
  }
 
}

```

```auto

```

#### 💻 Environment

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [January 3, 2022, 3:25am UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/2 "2022-01-03T03:25:08Z")

</div>

Hi, welcome! 👋

I just deployed your code and had a try, it worked well, just called the function `mint` twice

```auto
mint(Account, 0, "test link")
mint(Account, 1, "test link")

```

you can find all the transactions all at here: [SenecaNFT | 0xdFd5D67e46C80c4c9537039ea19e428E27C7777c (etherscan.io)](https://kovan.etherscan.io/address/0xdFd5D67e46C80c4c9537039ea19e428E27C7777c)

So I am not sure what is your problems, so could you please share your failed transaction?

---

<div class="post-metadata">

**Author:** ![Brevital](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/brevital/32/11924_2.png) [@Brevital](https://forum.openzeppelin.com/u/Brevital)\
**Post date:** [January 3, 2022, 4:32pm UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/3 "2022-01-03T16:32:20Z")

</div>

![Screen Shot 2022-01-02 at 7.48.16 PM](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/6/6fdfef3ddd3485c4a18de72899bee45dd4cad95b.png)  
This is the error I'm getting in Remix. I'm very novice at this. It seems that I've likely inadvertently changed something locally in Remix but I can't figure it out.

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [January 4, 2022, 12:27am UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/4 "2022-01-04T00:27:44Z")

</div>

Emmmm, so could you please share your parameters when you try to call `mint()` again?

---

<div class="post-metadata">

**Author:** ![Brevital](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/brevital/32/11924_2.png) [@Brevital](https://forum.openzeppelin.com/u/Brevital)\
**Post date:** [January 4, 2022, 3:50pm UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/5 "2022-01-04T15:50:40Z")

</div>

Just filling in the 3 inputs:  
to: 0xf53BCD08714938E53CC04b937434BA7063a3e839  
id: (putting in any number string)  
uri: This time I'm trying an IPFS link hosted on Pinata

Regardless of how I enter (or even leave blank), it pops this same error:

 ![Screen Shot 2022-01-04 at 10.50.10 AM](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/4/44006bed35e05be9ec4db77be0f4474b6877eb9d.png)

---

<div class="post-metadata">

**Author:** ![Brevital](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/brevital/32/11924_2.png) [@Brevital](https://forum.openzeppelin.com/u/Brevital)\
**Post date:** [January 4, 2022, 4:02pm UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/6 "2022-01-04T16:02:33Z")

</div>

OMG... I fixed it. I knew I was doing something STUPID...

I was entering in the same "Token ID"...making a duplicate, essentially.  
The error was telling me right there that the transaction would fail (in addition to using up gas).

The interesting part that screwed me up is that I was able to mint multiples with this contract on Ropsten using the same Token ID. It just added them as additional holdings under separate ERC-721 entries (different entry for each token ID it seemed)

It seems like there are small differences in the way Ropsten & Mainnet behave

---

<div class="post-metadata">

**Author:** ![Brevital](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/brevital/32/11924_2.png) [@Brevital](https://forum.openzeppelin.com/u/Brevital)\
**Post date:** [January 4, 2022, 6:22pm UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/7 "2022-01-04T18:22:23Z")

</div>

Realizing now that I'm STILL stuck though with my original issue I suppose, although a much simpler one I think:

The input for "uri"

I had assumed this was a simple URL link to an image, but it seems not. If I'm understanding right, you need a .json file linked with your ipfs image that has your metadata & such...

I'm not trying to do anything complicated here, just give an image a title and get it to display on Opensea, Mintable, etc...

What is the input format for that uri part?

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [January 5, 2022, 1:40am UTC](https://forum.openzeppelin.com/t/gas-estimation-failed-on-mint-function-erc-721-contract/22072/8 "2022-01-05T01:40:33Z")

</div>

Emmm, I think this can be an API, such as `https://my-json-server.typicode.com/abcoathup/samplenft/tokens/`, and maybe you can have a look in this tutorial, it explains about the `MetaData`

> [@Create an NFT and deploy to a public testnet, using Truffle](https://forum.openzeppelin.com/t/create-an-nft-and-deploy-to-a-public-testnet-using-truffle/2961):
>
> In this tutorial we will create a non-fungible token (NFT) and deploy to a public testnet. ERC721 is a standard for representing ownership of [non-fungible tokens](https://docs.openzeppelin.com/contracts/3.x/tokens#different-kinds-of-tokens), that is, where each token is unique such as in real estate or collectibles. We will use [Presets](https://docs.openzeppelin.com/contracts/3.x/api/presets) contracts in [OpenZeppelin Contracts 3](https://docs.openzeppelin.com/contracts/3.x/) to create an ERC721 and deploy using Truffle. Setting up the Environment We begin by creating a new project. $ mkdir mynft && cd mynft $ npm init -y Then we install [OpenZeppelin Contracts](https://docs.openzeppelin.com/contracts) which has …
