0

When i am trying to send signed transaction via ethereumjs-tx. I get this Returned error: invalid sender

web3Http.eth.getTransactionCount(myAddress,"pending").then(function(blockcount){
   
    result = web3Http.utils.toWei(amt.toString(), 'ether');
   
   
          count = blockcount;
    
         
          var rawTransaction = {
           "from":myAddress,
           "gasPrice":web3Http.utils.toHex(20* 1e9),
           "gasLimit":web3Http.utils.toHex(210000),
           "to":contractAddress,"value":"0x0",
           "data":contract.methods.approve(fromAddress,web3Http.utils.toHex(result)).encodeABI(),
           "nonce":web3Http.utils.toHex(count)
          }
         
          var transaction = new Tx(rawTransaction,{'chain':'rinkeby',hardfork: 'petersburg'});
          
          transaction.sign(Buffer.from(process.env.Key, 'hex'));
      
          web3Http.eth.sendSignedTransaction('0x'+transaction.serialize().toString('hex'))
          .on('receipt', ((data)=>{
            resolve(data);
           
          }))
3
  • 1. Make sure that process.env.Key doesn't start with 0x. – goodvibration Sep 19 '20 at 18:10
  • 2. The '0x'+ part seems redundant (and harmful). – goodvibration Sep 19 '20 at 18:10
  • Nope process.env.Key doesn't start with 0x and removing 0x+ part doesn't help – Curious.BCoder Sep 20 '20 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.