简体   繁体   中英

Sending signTransaction with web3.js and getting the issues

Blockchain, web3.js issue ---------------- 在此处输入图片说明

I am new on block-chain and try to make transactions using ropsten test network but getting errors

Thanks in advance if anyone can help me.


 exports.sendTransactions = () => {

      var admin = "0xEF9dE245F335e0f3ae8A9563FD54D001de1d3E2D";
      var contract_address = "0x39E2f0E87027093C6Ffe76A4d2f20AEE479E5f64";
      var tx = {
        from: admin,
        to: contract_address,
        gas: 184000,
        data: "",`enter code here`
        chainId: "1337"
      };
      web3.eth.accounts.signTransaction(tx, 'privateKey').then((hash) => {


        web3.eth.sendSignedTransaction(hash.rawTransaction).then((receipt) => {
          resolve();
        }, (error) => {
          console.log(error);
          reject(500);
        });
      }, (error) => {
        reject(500);
      });

    }

    { messageHash: '0x15e3f440015b35151c1343fb9a6be2497c082b47dbce607d32e80c10eff800f1',
      v: '0xa95',
      r: '0x4446233885e382fc9f297dc47fe9294be57623341b781eece94ce28b52bec6ed',
      s: '0x51b096eb07f73d5a30757300caf990b4083d001d2f6aea0fca280aafbea5593d',
      rawTransaction: '0xf8678085012a05f2008302cec09439e2f0e87027093c6ffe76a4d2f20aee479e5f648080820a95a04446233885e382fc9f297dc47fe9294be57623341b781eece94ce28b52bec6eda051b096eb07f73d5a30757300caf990b4083d001d2f6aea0fca280aafbea5593d' }

    Error: Returned error: invalid sender
        at Object.ErrorResponse (/home/ri-8/Desktop/tokenAI/node_modules/web3-core-helpers/src/errors.js:29:16)
        at /home/ri-8/Desktop/tokenAI/node_modules/web3-core-requestmanager/src/index.js:137:36
        at XMLHttpRequest.request.onreadystatechange (/home/ri-8/Desktop/tokenAI/node_modules/web3-providers-http/src/index.js:77:13)
        at XMLHttpRequestEventTarget.dispatchEvent (/home/ri-8/Desktop/tokenAI/node_modules/xhr2/lib/xhr2.js:64:18)
        at XMLHttpRequest._setReadyState (/home/ri-8/Desktop/tokenAI/node_modules/xhr2/lib/xhr2.js:354:12)
        at XMLHttpRequest._onHttpResponseEnd (/home/ri-8/Desktop/tokenAI/node_modules/xhr2/lib/xhr2.js:509:12)
        at IncomingMessage.<anonymous> (/home/ri-8/Desktop/tokenAI/node_modules/xhr2/lib/xhr2.js:469:24)
        at emitNone (events.js:110:20)
        at IncomingMessage.emit (events.js:207:7)
        at endReadableNT (_stream_readable.js:1059:12)
        at _combinedTickCallback (internal/process/next_tick.js:138:11)
        at process._tickCallback (internal/process/next_tick.js:180:9)

Ropsten的链ID为3(请参阅EIP 155 ),但是您提供了1337。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM