This question already has an answer here:

I'm making a simple time-lock contract in Solidity. In my funds withdraw function I have:

function withdraw_funds() public returns (bool) {
        if (getAccounts[msg.sender].amount > 0) {

            if(getAccounts[msg.sender].releasetime < now){
            return (true);
        else {

On the front end I'm using:

                else {

With the above function I get the transaction hash regardless of whether the funds were actually transferred or not.

Could someone please tell me the correct way to check the Boolean return value and display the transaction hash if the transfer was successful ?

marked as duplicate by Ismael, Richard Horrocks, Luiz Soares, Roman Frolov, Achala Dissanayake Jan 21 '18 at 10:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Instead of return(false) you can use revert() or maybe use events so on frontend you can have listeners to be triggered by each event.

I suggest read these:

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