0

i'm trying to store Ether inside a Contract and refund it when I call the function paypackEther(). Inside of the Remix IDE with the JavaScript VM it works perfectly, but when I execute it on Rinkeby with Mist, I can't get the stored ether. It's making me crazy...

What's my mistake?

pragma solidity ^0.4.24;

contract SimpleContract {


function () public payable  {
}

constructor() payable  public {
}

function paybackEther() public  {
    selfdestruct(msg.sender);
}

}

The contract adress is: 0x0b5933fd3D33F7d79C0e19e12A070fafA053Df57 https://rinkeby.etherscan.io/address/0x0b5933fd3d33f7d79c0e19e12a070fafa053df57

Thanks in advance :)

  • Can you give us a link to the rinkeby transaction where you tried and failed to get the ether back? Did the transaction revert, or fail silently? – Jesbus Dec 9 '18 at 11:05
  • Can you replace selfdestruct(msg.sender) with msg.sender.transfer(address(this).balance) and say if it works? – goodvibration Dec 9 '18 at 11:11
  • @JesseBusman Here's the contract adress: 0x0b5933fd3D33F7d79C0e19e12A070fafA053Df57 rinkeby.etherscan.io/address/… The latest transaction is 0x70b1860a8f1c9f2ec002e737744198a83f8d8182c6b853895991ffceec6201f9 I also published the Code of the Contract in Etherscan, to make it easier to understand my code. – Andreas Schmidt Dec 9 '18 at 12:11
  • @goodvibration I also tried this solution, but it makes no difference. I've got my code from github.com/PaulRBerg/contractz/blob/master/contracts/… This works perfect... – Andreas Schmidt Dec 9 '18 at 12:17
1

I just looked at your transactions, and I see that you are not calling the paybackEther() function at all:

All these transactions send 0 ether and 0 bytes of data to the contract. A call to paybackEther() would send 4 bytes of data to the contract.

You're most likely doing something wrong when trying to call the function in Mist. I don't know what, because I cannot look on your screen and see which buttons you are pressing :)

| improve this answer | |
  • Thank you for helping me! I tried it now on 3 different computers and indeed all the transactions have an input data of 0x. I'm almost sure, the fault is within my code... All the computer show the same problem. And other contracts work without problems... Do you have any other advice for me? – Andreas Schmidt Dec 9 '18 at 13:52
  • For example I tried this code: github.com/PaulRBerg/contractz/blob/master/contracts/… (Contract Destructible, fuction destroy) – Andreas Schmidt Dec 9 '18 at 13:54
1

I found one answer, but it's not very "clean": It seems like Mist needs an input parameter in the function paybackEther...

pragma solidity ^0.4.24;

contract SimpleContract {

bool public finished;

function () public payable  {
}

constructor() payable  public {
}

function paybackEther(bool newfinished) public  {

finished = newfinished;        
selfdestruct(msg.sender);
}

}
| improve this answer | |

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.