Hope everyone's doing well.
For the past few days I've been having issues with a payable function which I know is definitely working. How do I know it's working? Ether gets sent successfully on Remix.
The following code is from a section of my contract:
function payRent()
public
payable
onlyTenant
inState(State.Started)
equalValue {
landlord.transfer(msg.value);
paidrents.push(PaidRent({
id : paidrents.length + 1,
value : msg.value
})); }
Assume that landlord is an address which was previously stated within the contract.
I have also included the fallback payable function:
//fallback payable
function() public payable{}
The above functions work perfectly with Remix. I have created a React Application which would call this function and use the Metamask as the web3 provider. Within the function I use the return section as so:
return rentalAgreementInstance.payRent.sendTransaction({from: accounts[0], value: this.state.web3.toWei(this.state.rent, "ether"), gas:30000})
Instance has been properly initialized.
This is set to activate on a button click.
Everytime the button is clicked, Metamask provides me with a popup to confirm the transaction with the proper value defined. Now the issue arises once confirm is clicked.
The transaction gets completed, but no ether is deducted from the sender account, and no ether is received by the receiving account.
I assume I may be calling it incorrectly within the web3 return function of react.
If any more relevant details are required please let me know.
Some help would really be appreciated. Thank you all!
this.state.rent
?this.state.rent
is a value which can be set by the contract creator. Keep in mind I'm using a private node, Ganache specifically.