2

I deposited ETH into a simple contract, and I want to get it back. I have this function:

function refundBalance() public onlyOwner {
    uint256 balance = address(this).balance;
    msg.sender.transfer(balance);
    emit LogReturnedFunds(msg.sender, balance);
}

I call it via node and web3@1.0.0-beta.35 in the terminal:

contract.methods.refundBalance().call().then(console.log)

Alas, I only get this empty response: Result {} and no state update on Ropsten. Is there something I'm missing here?

1

try this:

`contract.methods.refundBalance().send().then(console.log)`. 

call is used for functions that do not change the state. They're decared as view or pure. However, refundBalance() does change the state. Therefore, use send

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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