Web3.js: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'sign' of undefined

Created on 6 Mar 2019  路  9Comments  路  Source: ChainSafe/web3.js

Description

Calling web3.eth.accounts.signTransaction(tx, privkey) result in this error. Versions prior to beta.47 work fine.

Expected behavior


Calling web3.eth.accounts.signTransaction() should return a signed tx.

Actual behavior

Steps to reproduce the behavior

const Web3 = require('web3')
const WEB3_HOST = 'https://mainnet.infura.io/...'
const web3 = new Web3(WEB3_HOST)

var tx = {
    gas: 100000,
    gasPrice: 4000000000
  }
signed_tx = web3.eth.accounts.signTransaction(tx, PRIVATEKEY)

Error Logs

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'sign' of undefined
    at Proxy._callee$ (/.../node_modules/web3-eth-accounts/dist/web3-eth-accounts.cjs.js:396:47)
    at tryCatch (/.../node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/.../node_modules/regenerator-runtime/runtime.js:288:22)
    at Generator.prototype.(anonymous function) [as next] (/.../node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (/.../node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (.../node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Gists

Versions

  • web3.js: 1.0.0-beta.47
  • nodejs: 10.15.1
  • browser:
  • ethereum node:

bug

Most helpful comment

I'm still getting this error in ^1.0.0-beta.48.

All 9 comments

Same for me.

Thanks for creating this issue! I will fix and release it asap.

I'm still getting this error in ^1.0.0-beta.48.

@lekevicius I've been downgrading to find a version that works. Down to version 1.0.0-beta.20 at the moment and no success. Did you find a version that works?

Same problem here

The fix seems to not yet be merged into the latest release (beta.48).
Would be nice if it were easier to figure out which release actually contains (or is gonna contain) the fix for a bug which was closed, otherwise those hitting the same bug and finding the issue are left behind confused.

This fix will get released this week or at least at the beginning of next week.

@mtsalenc I downgraded to 1.0.0-beta.46 and it works well.

@DiyLecko That version worked, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oktapodia picture oktapodia  路  3Comments

TinyWJL picture TinyWJL  路  3Comments

connectdotz picture connectdotz  路  3Comments

webersson picture webersson  路  3Comments

praveengupta0895 picture praveengupta0895  路  3Comments