2

When calling testnet contract ( https://testnet.etherscan.io/address/0xc03db39c18b6056f8c3a3a5495a1e11f3ff8885a ) method sendFundsToFriend:

/* Faucet: Send funds, 1 Ether, to a new contact/friend */
function sendFundsToFriend(address to) {
    if (to.balance > 1000000000000000000) {
        faucetResult(msg.sender, to, 'Friends balance higher than 1 Ether'); // Event Log
        throw; // If friend has enough funds (> 1 Ether), do not send anymore
    }
    if (this.balance < 1000000000000000000) {
        faucetResult(msg.sender, to, 'Faucets balance lower than 1 Ether'); // Event Log
        throw; // If SC funds are not enough(< 1 Ether), do not send funds
    }
    bool dummy = to.send(1000000000000000000);
    faucetResult(msg.sender, to, 'Sent 1 Ether to friends account'); // Event Log
}

it throws the following errors:

"Callback contain no result" => when calling contract method through solidity-browser and Metamask.

"Bad jump destination" => when calling contract method through geth node.
    Trace => https://testnet.etherscan.io/vmtrace?txhash=0xa3b522fe104ad9b34cbae4235b59296e624c42665f5e2d6d5b509f4f02c52904

According to Problem setting uint value to zero and https://www.reddit.com/r/ethdev/comments/5m6j1q/heres_an_interesting_solidity_problem_ese_problem/ it looks like a bug in Solidity, (Metamask case) due to Browser Solidity interacting with geth.

And "Bad jump destination" sometimes it is due to an invalid array index or the lack of "memory" keyword on local variable declarations, but none of those cases is present at sendFundsToFriend method, I think.

When runnig on local Javascript VM (no node connection) it throws this error:

VM Exception: invalid JUMP at ac4467b97a805884f19a44b98da45c3fe7c604bc2ce1eaabf19fd83a1126f253/692a70d2e424a56d2c6c27aa97d1a86395877b3a:7906

I have found out error throws when executing this condition:

if (this.balance < 1000000000000000000) {
    throw;
}

So, any idea what is wrong with this code? Any way to debug the code or find out more information about the errors? Thx!

Refs:

Error encountered during contract execution [Bad jump destination]

How to debug Bad jump destination error

Bad Jump Destination error

7
  • 1
    Hello. What do you want to do this line of code bool dummy = to.send(1000000000000000000); ? A boolean need to be compared to something to return a true or a false right? Commented Feb 1, 2017 at 11:37
  • The purpose of this code line is to send 1 ether to a given account. The boolean dummy is there just to avoid a Solidity warning message. Commented Feb 1, 2017 at 14:21
  • 1
    Oh okay, I did not aware that you could do this so as to avoid Solidity warning. Correct me if i'm wrong, but your faucetResult event should look like this: event faucetResult( address _from, address _to, string _comment ); ? Also the think that tickles my mind is this Callback contain no result. I do not see any callback mechanism in your code. Commented Feb 1, 2017 at 15:30
  • The event definition is the following: event faucetResult(address from, address to, string result); Is that correct? Commented Feb 1, 2017 at 16:31
  • 1
    Maybe the problem is related to the range of those big integer numbers. Have a look at this question: ethereum.stackexchange.com/questions/11346/… They are using the function web3.toBigNumber(...) in order to use geth with those big integers.
    – jap1968
    Commented Feb 2, 2017 at 17:01

1 Answer 1

1

It seems to me all errors come from the throw command. Once removed it works ok.

function sendFundsToFriend(address to) {
    if (to.balance >= 1000000000000000000) {
        faucetResult(msg.sender, to, 'Friends balance higher than 1 Ether'); // Event log
    } else if (this.balance < 1000000000000000000) {
        faucetResult(msg.sender, to, 'Faucets balance lower than 1 Ether'); // Event log
    } else {
        bool dummy = to.send(1000000000000000000);
        faucetResult(msg.sender, to, 'Sent 1 Ether to friends account'); // Event log
    }
}
1
  • 2
    Ho can be an error from throw? Have you investigated further?
    – niksmac
    Commented Feb 3, 2017 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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