# Why does my mint function throw an insufficent amount error?

**URL:** <https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752>\
**Category:** Smart Contracts\
**Tags:** erc721, openzeppelin-contracts, remix\
**Created:** [January 31, 2022, 11:57pm UTC](https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752 "2022-01-31T23:57:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jalapina](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jalapina/32/8924_2.png) [@Jalapina](https://forum.openzeppelin.com/u/Jalapina)\
**Post date:** [January 31, 2022, 11:57pm UTC](https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752/1 "2022-01-31T23:57:12Z")

</div>

**Hi everyone,**

I'm testing a smart contract on _ **REMIX** _, everything works but the mint function provided throws an insufficient amount error even though I have enough ether in my account.

It seems like theirs no ether being sent out.  
Any idea why this might be happening ?

 ![Screen Shot 2022-01-31 at 5.51.39 PM](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/8/8247e2c5df03e7cd3354958a6cf90fe11a80e5ea.png)

**CODE**

```auto
 uint256 public cost = 0.02 ether;

 function mint(uint256 _mintAmount) public payable {
    require(!paused, "The contract is paused!");
    require(msg.value >= cost * _mintAmount, "Need to send 0.02 ether");

    _mintLoop(msg.sender, _mintAmount);
  }

```

- The contract is not paused
- I have enough ether in my account

[The entire contract | MINT FUNCTION LINE 55](https://github.com/HashLips/hashlips_nft_contract/blob/main/contract/SimpleNftLowerGas.sol)

---

<div class="post-metadata">

**Author:** ![asmel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/asmel/32/11994_2.png) [@asmel](https://forum.openzeppelin.com/u/asmel)\
**Post date:** [February 1, 2022, 5:15am UTC](https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752/2 "2022-02-01T05:15:42Z")

</div>

Are you sure you are sending the amount of ether through the global variable msg.value

---

<div class="post-metadata">

**Author:** ![Jalapina](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jalapina/32/8924_2.png) [@Jalapina](https://forum.openzeppelin.com/u/Jalapina)\
**Post date:** [February 1, 2022, 3:02pm UTC](https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752/3 "2022-02-01T15:02:41Z")

</div>

I thought web3 asked the provider automatically.  
How can I make sure i'm sending it?

Theirs this value attribute but it won't let me enter 0.02

EDIT: I converted the ether to wei using [this](https://eth-converter.com/) and it worked

![Screen Shot 2022-02-01 at 8.54.30 AM](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/0/0310eb77555344f780d36bb356d217ea52d26204.png)

---

<div class="post-metadata">

**Author:** ![asmel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/asmel/32/11994_2.png) [@asmel](https://forum.openzeppelin.com/u/asmel)\
**Post date:** [February 1, 2022, 3:30pm UTC](https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752/4 "2022-02-01T15:30:40Z")

</div>

the provider does not ask you, one as a developer when creating the function with web3.js, has to pass the value as a parameter, if in value you put the amount of ether and it has to change from Gwi to ether

---

<div class="post-metadata">

**Author:** ![Jalapina](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/jalapina/32/8924_2.png) [@Jalapina](https://forum.openzeppelin.com/u/Jalapina)\
**Post date:** [February 1, 2022, 4:59pm UTC](https://forum.openzeppelin.com/t/why-does-my-mint-function-throw-an-insufficent-amount-error/23752/5 "2022-02-01T16:59:57Z")

</div>

I was actually minting 2 tokens and forgot to double the amount sent  
it works now by sending wei
