0

This is my Javascript code. I keep getting an error that states

(node:30062) UnhandledPromiseRejectionWarning: TypeError: privateKey.startsWith is not a function

I am using node 12.1.0 & web3^1.0.0-beta.55

   const contract = new web3.eth.Contract(_ABI);

   web3.eth.accounts.wallet.add({
        address:_publicKey,
        privateKey: _privateKey
    });
    const contract_Instance = await contract.deploy({
        data: _bytecode,
        arguments: _constructor_args})
        .send({
        from: _adminAddress,
        gas: 1500000,
        gasPrice: '20000000000'
    });

What am I doing wrong here?

8
  • 2
    Your _privateKey should be a string. Commented May 24, 2019 at 14:38
  • I changed _privateKey to _privateKey.toString() & now I get this error: UnhandledPromiseRejectionWarning: Error: No privateKey given to the TransactionSigner.
    – pjonson2
    Commented May 24, 2019 at 15:37
  • address should be the account's address, not the account's public key. And then from should be that same address (I'm not sure what _adminAddress is). Commented May 24, 2019 at 16:29
  • _adminAddress is the _publicKey. How do I get the account's address?
    – pjonson2
    Commented May 24, 2019 at 16:39
  • How did you get the public key? Commented May 24, 2019 at 16:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.