0

I am trying to set the price of a Transaction

According to the documentation :

value (in wei): the amount of Wei to transfer from the sender to the recipient.

But when I put this value : ( for 0.04eth) -> I get 73 eth in metamask :)

( I am on rinkeby network)

here is my code:

window.contract = await new web3.eth.Contract(contractABI.abi, contractAddress);//loadContract();
     const transactionParameters = {
        to: contractAddress, // Required except during contract publications.
        from: window.ethereum.selectedAddress, // must match user's active address.
        'data': window.contract.methods.mint(window.ethereum.selectedAddress,number).encodeABI(),
        value: String(40000000000000000) 
      };
    try {
        const txHash = await window.ethereum
            .request({
                method: 'eth_sendTransaction',
                params: [transactionParameters],
            });
        return {
            success: true,
            status: " Check out your transaction on Etherscan: https://ropsten.etherscan.io/tx/" + txHash
        }
    } catch (error) {
      console.log(error);
        return {
            success: false,
            status: " Something went wrong: " + error.message
        }
    }
TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

I found a workaround, it seems the eth_sendTransaction doesn't handle the value well. By using it like that it is now working.

window.contract.methods.mint(window.ethereum.selectedAddress,  1).send({
         from: window.ethereum.selectedAddress, value: web3.utils.toWei(String(0.05*number),"ether")});
m4n0
  • 29,823
  • 27
  • 76
  • 89