3

I'am trying to send ERC20 from 1 address to another but i'am getting that error :

Blockquote Contract 0x557e4cca38277b9bf9f1f1bf333dfe4b0ac5541a Warning! Error encountered during contract execution [Bad jump destination] ERC-20 Token Transfer Error (Unable to locate Corresponding Transfer Event Logs), Check with Sender. Blockquote

Here my code, can you help me to find the issue please ?

  var address = req.body.address;

  var contractAddress = "0x557e4cca38277b9bf9f1f1bf333dfe4b0ac5541a"
  var fromAddress = myaddress
  var privateKey = privatekey
  var toAddress = req.body.address
  var transferAmount = 1;

// Create an async function so I can use the "await" keyword to wait for things to finish
const main = async () => {
  // This code was written and tested using web3 version 1.0.0-beta.26
  console.log(`web3 version: ${web3.version}`)

  // Determine the nonce
  var count = await web3.eth.getTransactionCount(fromAddress);
  console.log(`num transactions so far: ${count}`);

  // This file is just JSON stolen from the contract page on etherscan.io under "Contract ABI"
  var abiArray = JSON.parse(fs.readFileSync(path.resolve(__dirname, './tt3.json'), 'utf-8'));
  // This is the address of the contract which created the ERC20 token
  var contract = new web3.eth.Contract(abiArray, contractAddress, { from: fromAddress });
  //var contract = new web3.eth.Contract(abiArray, contractAddress, { from: myAddress });

  // How many tokens do I have before sending?
  var balance = await contract.methods.balanceOf(fromAddress).call();
  console.log(`Balance before send: ${balance}`);
  // I chose gas price and gas limit based on what ethereum wallet was recommending for a similar transaction. You may need to change the gas price!
  var rawTransaction = {
      "from": fromAddress,
      "nonce": "0x" + count.toString(16),
      "gasPrice": 2000000000,
      "gasLimit": 300000,
      "to": contractAddress,
      "value": transferAmount,
      "data": contract.methods.transfer(toAddress, transferAmount).encodeABI(),
      "chainId": web3.eth.net.getId()
  };

  // Example private key (do not use): 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109'
  // The private key must be for myAddress
  var privKey = new Buffer(privateKey, 'hex');
  var tx = new Tx(rawTransaction);
  tx.sign(privKey);
  var serializedTx = tx.serialize();

  // Comment out these three lines if you don't really want to send the TX right now
 console.log(`Attempting to send signed tx:  ${serializedTx.toString('hex')}`);
  var receipt = await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'));
  console.log(`Receipt info:  ${JSON.stringify(receipt, null, '\t')}`);

  // The balance may not be updated yet, but let's check
  balance = await contract.methods.balanceOf(fromAddress).call();
  console.log(`Balance after send: ${balance}`);
}

main();
  • You make up a contract address (0x55) which obviously no contract is deployed at, and you're surprised to get a "bad jump" error? – goodvibration Dec 31 '18 at 8:02
  • Here the contract address : 0x557e4cca38277b9bf9f1f1bf333dfe4b0ac5541a – Mickaël Canu Dec 31 '18 at 8:11
  • Well why are you using var contractAddress = "0x55"??? – goodvibration Dec 31 '18 at 8:12
  • I follow an example from that website medium.com/bitfwd/… – Mickaël Canu Dec 31 '18 at 8:14
  • var contractAddress = "0x55" was only for that example. I used the entire address – Mickaël Canu Dec 31 '18 at 8:16
0

Turning a comment into an answer:

ERC20 function transfer is not payable.

It only transfers tokens from one account to another.

There is no need to send ETH to this function, and moreover, doing so will cause it to revert.

So using "value": transferAmount with transferAmount > 0 is wrong.

0

Your code is the javascript you've used to generate & sign the transaction, but the error is a solidity error. And it is very likely due to the fact that your contract address is 0x55, which is somewhat short of an actual, 20 byte long ethereum address. And so you're getting a bad jump destination error because there's no code at all at the 0x55 destination you've supplied.

Instead, for your code to work, you'll need an actual ERC20 contract deployed to your network of choice, whose real address you can then use.

  • I didn't write the entire address on previous sample code. Here the real contract address 0x557e4cca38277b9bf9f1f1bf333dfe4b0ac5541a – Mickaël Canu Dec 31 '18 at 8:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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