How to retrieve the return value of contract method called with sendTransaction

ajlopezajlopez Member Posts: 2
We are using the token sample from

There is a method sendCoin that returns a boolean. But the method is called using sendTransaction, that only returns the transaction hash. Is there any way to retrieve the return value? We tried getTransactionReceipt with the original returned transaction hash, but we didn't find the return value in the transaction data.


  • JackThorpJackThorp Member Posts: 4
    Transactions cannot return results to web3.js. Note this! The [sendCoin] function returns a value but this cannot be checked in your test. This method is a transaction (i.e., something that modifies values or send ether), and the result of a transaction to web3.js is a transaction hash (if you printed the result it’ll be a long hex/weird-looking object). So why add a return value to the sendCoin method at all? The return value can be read in Solidity, such as by another contract that calls sendCoin(). So Solidity contracts can read return values from a transaction, but web3.js transaction calls cannot. On the other hand, other contracts can’t use Events (discussed below) which is how you can monitor transactions in web3.js.

    Source: A 101 noob intro to programming smart contracts on ethereum
Sign In or Register to comment.