Invalid email sender - fail to deploy to blockchain network

by Игор Ташевски   Last Updated October 17, 2019 13:28 PM - source

Description

I'm trying to deploy a contract to rinkeby network, but everytime I like to deploy the contract it throwing error as invalid sender.

Code

const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');

const { interface, object: bytecode } = require('./compile');

const provider = new HDWalletProvider(
  'mnemonic phrases...',
  'https://rinkeby.infura.io/v3/bba91a6c349c44afbde264a1bda1af75'
);

const web3 = new Web3(provider);

(async () => {
  const accounts = await web3.eth.getAccounts();

  const result = await new web3.eth.Contract(interface)
    .deploy({ data: bytecode })
    .send({ from: accounts[0], gas: '1000000' }); 

  console.log('interface', interface);
  console.log('Contract deployed to', result.options.address);

})();

Versions

"@truffle/hdwallet-provider": "^1.0.19"

"web3": "^1.2.1"

"solc": "^0.5.11",

Deploy command

"start": "node deploy.js"

Error logs

Attempting to deploy from account [ '0x.....' ] Error: invalid sender at D:\projects\blockchain\demo\node_modules\web3-provider-engine\subproviders\provider.js:18:36 at XMLHttpRequest.request.onreadystatechange (D:\projects\blockchain\demo\node_modules\web3-providers-http\src\index.js:96:13) at XMLHttpRequestEventTarget.dispatchEvent (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22) at XMLHttpRequest._setReadyState (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14) at XMLHttpRequest._onHttpResponseEnd (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14) at IncomingMessage. (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) Error: invalid sender at D:\projects\blockchain\demo\node_modules\web3-provider-engine\subproviders\provider.js:18:36 at XMLHttpRequest.request.onreadystatechange (D:\projects\blockchain\demo\node_modules\web3-providers-http\src\index.js:96:13) at XMLHttpRequestEventTarget.dispatchEvent (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22) at XMLHttpRequest._setReadyState (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14) at XMLHttpRequest._onHttpResponseEnd (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14) at IncomingMessage. (D:\projects\blockchain\demo\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19)

BR, Igor



Answers 1


Try:

    const contract = await new web3.eth.Contract(JSON.parse(interface))
      .deploy( { data:"0x"+bytecode} )
      .send( { gas: '5000000', from:accounts[0]});

Otherwise please make sure that your accounts array includes actual values.

Niklas Feurstein
Niklas Feurstein
October 17, 2019 12:51 PM

Related Questions


liason entre web3 et nodejs

Updated July 31, 2017 12:28 PM

Load Smartcontract in Nodejs

Updated August 19, 2019 11:28 AM



geth javascript console

Updated August 30, 2017 08:28 AM