1

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});

1 Answer 1

1

Seems to be related to the latest Google Chrome release (59.0.3071.115). I'm experiencing the same issues as you. Metamask acts like the Tx went through, but nothing shows up in testrpc output.

The Metamask gituhub issues page is also feeling the pain. See links below.

https://github.com/MetaMask/metamask-plugin/issues/1705 https://chromereleases.googleblog.com/2017/06/stable-channel-update-for-desktop_26.html

7
  • I see. By testrpc logs, do you mean the console output? if not, how do I check those logs? Any workarounds to this issue? Thanks!
    – jwu
    Jul 2, 2017 at 19:15
  • Yes, console output. Thanks for helping clarify. Edited post accordingly.
    – cDitch
    Jul 3, 2017 at 20:03
  • In my testrpc console I see this when I approve a tx on MetaMask: eth_sendRawTransaction Transaction: <address> Contract created: <address> Gas usage: 0xcf08 Block Number: 0x09 Block Time: Thu Jul 06 2017 19:51:33 GMT-0300 (-03) So there seems to be a record in the console. But when I do sendTransaction() directly in the console, it reports eth_sendTransaction instead of eth_sendRawTransaction
    – jwu
    Jul 6, 2017 at 22:55
  • Interesting. Can you try web3.eth.getTransactionReceipt(<address>) and see what it says? Also, do you have a gist you can link to of the code you've got?
    – cDitch
    Jul 7, 2017 at 23:47
  • here's my code: gist.github.com/jw122/bda506dc831e200ac5eb397b36cb2db5 The eth transfer happens in the makePayment() function
    – jwu
    Jul 10, 2017 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.