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");
_safeMint(id,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");
_safeMint(id,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]
yourContract.mint(
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 });