关灯

ERC-20 Token Transfer Error : Bad jump destination

  [复制链接]
区块链技术 发表于 2019-1-1 13:06:39 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x

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();



上一篇:OpenZeppelin crowdsale token ownership
下一篇:i am trying to write code for sending feedback and then calculating total feedba
版权申明:此文如未标注转载均为本站原创,自由转载请注明 本贴地址:https://xuesq.cn/thread-109458-1-1.html 上篇帖子: 做好当下即是未来,你好,2019! 下篇帖子: 寄望2019:于寒冬中守望参天大树|碳链价值 transfer jump destination
回复

使用道具 举报

 

精彩评论2

正序浏览
区块链技术 发表于 2019-1-1 13:22:44 | 显示全部楼层
 

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.

回复

使用道具 举报

 
 楼主| 区块链技术 发表于 2019-1-1 13:31:17 | 显示全部楼层
 

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.

回复

使用道具 举报

 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

排行榜

关注我们:微信订阅号

官方微信

APP下载

全国服务邮箱:

admin@xuesq.cn

公司地址:重庆南岸区学府大道

运营中心:重庆微生派网络工作室

邮编:610066 Email:1401171837#qq.com

Copyright   ©2017-2018  中比特Powered by©xuesq.cn!技术支持:中比特    ( 蜀ICP备16009247号-1 )繁体中文

JS of wanmeiff.com and vcpic.com Please keep this copyright information, respect of, thank you!JS of wanmeiff.com and vcpic.com Please keep this copyright information, respect of, thank you!