I am getting the error
React Function :
const {
Moralis,
user,
web3,
isAuthenticated,
isWeb3Enabled,
isWeb3EnableLoading,
} = useMoralis();
const transfer = async () => {
if (!isWeb3Enabled && !isWeb3EnableLoading) await Moralis.enableWeb3();
const currentUser = user.get("ethAddress");
let Charity = new web3.eth.Contract(contractABI, contractAddress);
const id = await Charity.methods
.transferFunds(proposalID, message)
.send({
from: currentUser,
value: Moralis.Units.ETH(amount),
})
.then(() => {
toast.success(`Successfully Donated ${amount} MATIC!`, toastStyles);
});
};
Solidity Function:
function transferFunds(uint256 proposalID, string memory message)
public
payable
{
if (proposalRegistry[proposalID].proposalExists) {
bytes32 NGOId = proposalRegistry[proposalID].postOwner;
if (ngoRegistry[NGOId].ngoExists) {
address receiver = ngoRegistry[NGOId].wallet_address;
if (msg.sender != receiver) {
payable(receiver).transfer(msg.value);
emit Transfer(
proposalID,
msg.sender,
receiver,
msg.value,
message,
block.timestamp
);
proposalRegistry[proposalID].amt += msg.value;
if (proposalReachedThreshold(proposalID)) {
proposalRegistry[proposalID].closed = true;
}
}
}
}
}
function proposalReachedThreshold(uint256 proposalID)
private
view
returns (bool)
{
return
proposalRegistry[proposalID].amt >=
proposalRegistry[proposalID].amtThreshold;
}
Can someone tell me the code to send money via the “transferFunds” solidity function through react?