The problem is that when I am clicking a button using the safeMint function, I do not know how to input a value for the cost to mint. So I am essentially minting with air. enter image description hereenter image description here

I have included a mintRate and a require statement to make sure that the transaction has to be at least 1 ether, but in my application I do not know how to include a price. I works without a price but I would like to include a price to mint. enter image description here

This is the code for what I have so far i just need to make it have a value of 1 ether for minting the nft.enter image description here

2 Answers 2


If you testing in remix you can change your input from wei to eth ,then input 1 eth or any value that you want .

another way is input as a wei, 1 ether == 10 ** 18 wei

so if you want to set your input as a wei you need 1 and 18 zero 's:


and also you can use web3js documentation if want to deploy your contract in vsCode or ...



I think the question is not very clear but what I understand is that you want to do this:

1.- create a token that can be minted for 1ETH, to do this you must set the price on contract level by checking the value of a transaction

function mint(uint256 id, uint256 amount) external payable {
  require(msg.value == 1000000000000000000, "invalid paid amount");

note of the code: 1000000000000000000wei == 1eth

2.- Send a transaction with 1eth

I usually do something like this to have a bit more control:

uint256 price;

function setPrice(uint256 foo) external onlyOwner{
  price = foo;

function mint(uint256 id, uint256 amount) external payable {
  require(msg.value == price, "invalid paid amount");

Now you should be able to call the mint function and you now must input some eth in there.. Example call in typescript + truffle:

it("Should succed - mints a token with 1eth fee",async () =>{
  const price = ethers.utils.parseEther("1")
  expect(await yourContract.mint(1, 1, {value: price})).to.be.ok

Example function in Python with brownie:

from brownie import yourContract, accounts, config
from web3 import Web3
mintAmount = 2
payable = mintAmount * 0.01

def mint():
    dev = accounts.add(config["wallets"]["from_key"])

    # Get the latest deployed contract
    yourContract = contract[len(contract) - 1]
        mintAmount, {"from": dev, "value": Web3.toWei(payable, "ether")}

If you want to add value in the FE ie react you need to do something like this, more info on how to input value here and how to initialize contracts in React + metamask here:

yourContract.mint(1,1, { value: price });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.