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);

        privateKey: _privateKey
    const contract_Instance = await contract.deploy({
        data: _bytecode,
        arguments: _constructor_args})
        from: _adminAddress,
        gas: 1500000,
        gasPrice: '20000000000'

What am I doing wrong here?

  • Your _privateKey should be a string. – goodvibration May 24 at 14:38
  • I changed _privateKey to _privateKey.toString() & now I get this error: UnhandledPromiseRejectionWarning: Error: No privateKey given to the TransactionSigner. – pjonson2 May 24 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). – goodvibration May 24 at 16:29
  • _adminAddress is the _publicKey. How do I get the account's address? – pjonson2 May 24 at 16:39
  • How did you get the public key? – goodvibration May 24 at 16:49

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.