[Ethereum] Error During Token Contract Execution

contract-debuggingexceptionstokenstransactions

Getting an error in executing a token contract:

An error occurred during contract execution: invalid jump destination (PUSH1) 2

http://testnet.etherscan.io/vmtrace?txhash=0xfd2f51d19e32d7b4be5fe63cb46f9207c8f58120b4156d77c20408c1a7ab4dfa

Using this transaction code:

myContractInstance.transferFrom(fromAddress, toAddress, transferValue, {from: web3.eth.accounts[0], gas: 3000000});

Is there an obvious reason I'm overlooking? Thanks

http://testnet.etherscan.io/vmtrace?txhash=0xfd2f51d19e32d7b4be5fe63cb46f9207c8f58120b4156d77c20408c1a7ab4dfa

Best Answer

Replicating ERROR: invalid jump destination (PUSH1) 2

I don't know what source code you were executing, but I can replicate the invalid jump destination (PUSH1) 2 error by running the following function:

contract TestInvalidJumpLoc {

    function testInvalidJumpLocation() public constant returns (uint[5]) {
      uint[5] memory data;
      uint j = 1;
      j = j - 2;
      data[j] = 1235;
      return data;
    }

And executing the function to get the following results:

 testInvalidJumpLocContract.testInvalidJumpLocation()
 ...
 PC 00000304: JUMP GAS: 49978004 COST: 8 ERROR: invalid jump destination (PUSH1) 2
...

This error could have been caused by some other parts of your code, but an invalid array index definitely generates this message.

The above snippet was taken from my answer to the question Bad Jump Array solidity and Data location .

Related Topic