I'm making a simple dApp that sends funds from one account to another using Truffle + MetaMask on testrpc. In my app.js, I have a pay() function that calls
web3.eth.sendTransaction({from: account1, to: account2, value: web3.toWei(amount,"ether")}
When the function is triggered via the HTML page and the transaction pops up on MetaMask, the funds get deducted from account1 but do not show up on account2. I think it might be because the contract hasn't been properly mined or MetaMask is slow? The chrome extension shows the contract as "Published", not "Pending" though.
If I perform the same command via the truffle console, the transaction gets processed appropriately, and I can verify that the value has been transferred from account1 to account2. How can I fix this? I've tried restarting chrome.
Link to my app.js file: https://gist.github.com/jw122/bda506dc831e200ac5eb397b36cb2db5
Link to solidity contract: https://gist.github.com/jw122/c561c8059ca239df6623db9080805634
I deploy the contract in 2_deploy_contract.js with:
deployer.deploy(Purchase, web3.eth.accounts[1], web3.eth.accounts[2], {from: web3.eth.accounts[0], gas: 4000000});