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]
bool dummy = to.send(1000000000000000000);
? A boolean need to be compared to something to return atrue
or afalse
right?event faucetResult( address _from, address _to, string _comment );
? Also the think that tickles my mind is thisCallback contain no result
. I do not see any callback mechanism in your code.web3.toBigNumber(...)
in order to usegeth
with those big integers.