Contract Deployment Error – Resolving Provided Address Invalid and Checksum Test Failures

contract-deploymentgo-ethereumweb3js

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?

Best Answer

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.

Related Topic