Skip to content
Advertisement

Provided Address is invalid, the capitalization checksum test failed

I am trying to send a method on a contract using web3. I’m creating an account using the privateKeyToAccount method but when sending the method on the contract I get the following error:

Provided address [object Object] is invalid, the capitalization checksum test failed, or it’s an indirect IBAN address which can’t be converted.

Am I missing a step? I already created an instance of web3 and the contract interface works. I attached part of the code below. Thanks in advance for the help.

const web3 = new Web3(
    new Web3.providers.WebsocketProvider(
        'wss://rinkeby.infura.io/ws/v3/<api>'
    )
);

const dummyPrivateKey = '0x38544e1555a3553829219281253d2400fa20ebbd922fdh3918a7s2b53b9e1358';
const accounts = web3.eth.accounts.privateKeyToAccount(dummyPrivateKey);

await contract.methods // add username
    .addMessage(_username, _message)
    .send({ from: accounts });

Advertisement

Answer

Petr is right. I missed the part where you are giving the whole object instead of address.

But if you want to checksum an address. You can simply use Web3 utility function web3.utils.toChecksumAddress(address) to convert. More details here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement