[SOLVED] Send ETH in a transaction for minting (Purchase price)

Hi, I am almost done with my Moralis project I am missing one last thing now which is add amount of ETH in a transaction when the user is minting an NFT.
So let’s say he click mint I want to send 1ETH because in my smart contract I check the

msg.value > 1 eth

I am using the useWeb3executeFunction() hook and it works fine except that since my smart contract is expecting a certain amount of ETH in the message the transaction is always declined with the following message:

message":"execution reverted: Not enough funds" // message returned from my smart contract

I am not sure how to do this, because I haven’t read anything on the documentation for that or I am blind :smiley:

You need to add msgValue: Moralis.Units.ETH(<AMOUNT_OF_ETH>) to your options: https://docs.moralis.io/moralis-dapp/web3/web3#transfering-native-crypto-in-contract-method-example

1 Like

Ok thanks, I must have miss this information. I want to make the transaction using fromWei() but I get another error:

Error: invalid BigNumber string (argument="value", value="0.000000000000000005", code=INVALID_ARGUMENT, version=bignumber/5.6.0)

I’m trying to send 5eth in the transaction so I should put something like why do I get the error above?

 Moralis.Units.FromWei(5,18)

Use Moralis.Units.ETH("5") rather

1 Like

Ok thanks I will use this function. Do you know why I am getting the error above by any chance?

x = Moralis.Units.FromWei(5,18)
=>
'0.000000000000000005'

That is not 5 ETH

why would be 5eth with this function then? And why am I getting the error I wrote above?

EDIT: After rereading this morning everything I have understood the function. Thanks

1 Like

This was useful. It took me hours to find that msgValue is needed. It doesn’t mention msgValue in the up to date documentation. I think they should add it. https://github.com/MoralisWeb3/react-moralis#useweb3executefunction