Hi, trying to call a function from frontend app, but metamask keep saying that "you sending 0 ethers". Have idea why, anyone knows what is the problem?
ABI:
{
"inputs": [
{
"internalType": "uint256",
"name": "_ethAmount",
"type": "uint256"
}
],
"name": "fund",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},

the function in js app that I call
const tx = await contract.fund(2)
I'm stuck....

Jan 17, 2024, 4:09 PM
contract 0x8C9F370a0fe0132329Cd5FC8f8962914dC6e4e89
Jan 17, 2024, 4:10 PM
The function is marked as payable.

You need to send Ether when calling the function.

Use this code below. Edit the value as you please;


  const value = ethers.utils.parseEther("1"); // Convert 1 Ether to wei
  const tx = await contract.fund({ value: value });
  await tx.wait();
 
Jan 24, 2024, 11:52 AM

© 2024 Draquery.com All rights reserved.