0

I have the following code:

var account = web3.utils.toChecksumAddress("0x249eb..")
const accounts = await web3.eth.getAccounts();

let Contr = new web3.eth.Contract(abi, {from: account, gas: 47000, data: bytecode})

await  Contr.deploy({ data: bytecode }).send({ from: account, gas: '1500000', gasPrice: '30000000000000'})
    .then(function(newContractInstance){ console.log(newContractInstance) });

And I am getting the following error when I try to deploy().send() the contract:

Script failed: Error: Provided address "[object Object]" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted.

The provided address is the same one than the one used for getting the contract Contr by new web3.eth.Contract but, in this case, I dont get any error and the output is correct.

I have been checking another questions related with this error and I didnt get any solution.

I tried with account, accounts[0], and the address directly '0x249..'. I am using web3 1.0.0. Any idea how to solve this?

  • What happens when you make the first line explicitly synchronous, ie: var account = await web3.utils.toChecksumAddress("0x249eb..") – AnAllergyToAnalogy Feb 8 at 2:01
  • @AnAllergyToAnalogy It is the same error result – sapiensapiens Feb 8 at 2:02
  • Can you console.log(account) immediately before the deploy line? – AnAllergyToAnalogy Feb 8 at 2:09
  • Yes, it is the correct account: 0x249eb.. – sapiensapiens Feb 8 at 2:14
  • From the code you've provided it's hard to see precisely where it's happening, but from this part Provided address "[object Object]", it seems like you're passing a Javascript object where a string (with the address) should be. It's implicitly converting the object to the string "[object Object]" and then that isn't an address obviously. Are you omitting anything from the code you provided? – AnAllergyToAnalogy Feb 8 at 2:29
0

You've got some superfluous (and incorrectly placed) data on this line:

let Contr = new web3.eth.Contract(abi, {from: account, gas: 47000, data: bytecode})

your code should execute correctly if you change it to

let Contr = new web3.eth.Contract(abi)

as the deploy line takes care of the from account, the gas and the bytecode.

The new web3.eth.Contract function takes the following arguments (as per the docs):

new web3.eth.Contract(jsonInterface, address, options)

So it was interpreting this object: {from: account, gas: 47000, data: bytecode} as the address for a previously deployed instance of your contract.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.