0

I have a very simple contract with a withdraw function.

contract PayTest {
function() public payable {
}

function withdraw() {
    msg.sender.transfer(4000000000 wei);
}

}

When I try it in the JavaScript VM, it works. But when I change to localhost and try to run it with Testrpc, I get:

VM Exception while processing transaction: out of gas 

I cannot run Geth so I need to work with TestRPC. But that above does not work.

Thank you for helping!

0

First you deploy the contract.

Then you send the contract some funds. With testrpc, the accounts are funded with 100 ether and are unlocked, so you can then send of that the contract.

The contract is going to work if it has funds to send.

Hope it helps.

| improve this answer | |
  • Thank you. I did what you said, but it still doesn't work. Just to make clear, when I try it in the Javascript VM and it works without any errors there, will it work on Mainnet or on any Testnet (like ropsten) too? It would still be great if I could make it work on my Privatenet. – dkb Mar 4 '18 at 21:26
  • Generally, yes, and the contract looks like it should work. The most common oversight is forgetting to unlock the account as geth requires because testrpc/ganache-cli doesn't insist on that step. Have a look over here for a solution to a bit of a nuisance - the unlock expires rather quickly. Maybe this will help. ethereum.stackexchange.com/questions/10160/… – Rob Hitchens Mar 5 '18 at 2:49
  • No, it's because geth generally does not work for me. First thing is, it does start the miner only after some minutes and next thing is, if I deploy a contract, it comes in the console but on Remix it says "1 Pending transaction" which does never change. Can't work anymore with geth. – dkb Mar 5 '18 at 12:10

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.