Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Account.signTransaction(tx, callback) error #2571

Closed
mmshihov opened this issue Mar 25, 2019 · 0 comments · Fixed by #2572
Closed

Account.signTransaction(tx, callback) error #2571

mmshihov opened this issue Mar 25, 2019 · 0 comments · Fixed by #2572
Labels
Bug Addressing a bug

Comments

@mmshihov
Copy link

Description

After updating from 1.0.0-beta.35 to 1.0.0-beta.50 I have got a problem with this code snippet in my program:

let decryptedAccount = web3.eth.accounts.decrypt(V3keystoreStr, password);
let baseNonce        = await web3.eth.getTransactionCount(decryptedAccount.address);

let paramObj         = {from: decryptedAccount.address, gas: TX_GAS_LIMIT, gasPrice: 0 };

let contract = new web3.eth.Contract(contractAbi, contractAddress, paramObj);
let txData   = contract.myMethod(...myMethodParams).encodeABI();

let tx = {
    from:      decryptedAccount.address, 
    to:        contractAddress,
    data:      txData,

    gas:       TX_GAS_LIMIT,
    gasPrice:  0,            // JP Quorum
    chainId:   CHAIN_ID,

    nonce:     baseNonce
}

let signedTx = await decryptedAccount.signTransaction(tx);

Expected behavior

Raw transaction (tx) should be signed, and returned in signedTx.

Actual behavior

I've got the error:

TypeError: this.accounts.signTransaction is not a function at Proxy.signTransaction (/var/work/test-1by1-4/dsd/tests/node_modules/web3-eth-accounts/dist/web3-eth-accounts.cjs.js:65:28)

I think the problem in web3.js/packages/web3-eth-accounts/src/models/Account.js module. So in my code:

  let decryptedAccount = web3.eth.accounts.decrypt(V3keystoreStr, password);

The web3.accounts.decrypt(...) function is called. And it calls Account.fromPrivateKey(...):

// Account.js: line 128:
static fromPrivateKey(privateKey, accounts = {}) {
    return new Account(fromPrivate(privateKey), accounts.transactionSigner);
                                                // Account.accounts = transactionSigner
}

When I call:

let signedTx = await decryptedAccount.signTransaction(tx);

It calls:

// Account.js:  line 60:
signTransaction(tx, callback) {
    return this.accounts.signTransaction(tx, this.privateKey, callback);
                         // no signTransaction(...) in transactionSigner object
}

And it is no signTransaction(...) function in transactionSigner object.

Versions

  • web3js: 1.0.0-beta.50
  • nodejs: v8.11.3
  • ethereum node: JP Quorum
@nivida nivida added the Bug Addressing a bug label Mar 25, 2019
@nivida nivida mentioned this issue Mar 25, 2019
12 tasks
@nivida nivida mentioned this issue Mar 28, 2019
12 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants