I'm trying to call a function on web3, but it doesn't get executed on web3. It just doesn't popup Metamask wallet to ask for the transaction approval, so it doesn't execute.
Solidity function:
function Deposit(uint _amount) payable public{
require(msg.value == _amount);
funds[msg.sender] += _amount;
}
Function on web3
deposit = async(depositAmount)=>{
const web3 = window.web3
const ethers = web3.utils.toWei(this.depositAmount.value, 'ether')
await web3.contract.methods.Deposit(depositAmount).send({from: this.account, value: ethers})
}
How is the function called
<form className="deposit" onSubmitCapture={(event) => {
event.preventDefault()
const amount = this.amount
this.deposit(amount)
}}>
<input type="text" className="inputs" placeholder="Amount to deposit"
ref={(input)=>this.amount = input}/>
<input type="submit" className="btn" value="DEPOSIT"/>
</form>
I'm loading web3 and loading blockchain data correctly, and deposit function is called in a button component. Just wanted to know if it has something to do with this code, or the problem might be somewhere else. The smart contract is correctly migrated with truffle and ganache.