I have contract and function which accepts ether. How can I transfer ether from contract to any other wallet?

I'm using ganache-cli. Function work, and I spent 10 eth on contract(private network). Now I want to get them back

  contract Account {
    mapping (address => uint) balance;

            function accept(uint postId) payable public {
                balance[msg.sender] += msg.value;
                uint beforeWeight = posts[postId].weight;

this function takes my ether from wallet, I want to take eth from contract to my wallet

 function transfer(uint amount) payable public {

  • So what's wrong with the transfer() function? where is the error what is not working? how did you check? – cleanunicorn Mar 31 '18 at 15:54
  • when i call this metod msg sender loose eth instead of receiving eth from contract. – Leap Mar 31 '18 at 19:11

Your Answer

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

Browse other questions tagged or ask your own question.