I have trouble sending an address to a deployed contract, my function looks like this:

function addNote(uint _value, address _owner) public { 

and when I'm sending the parameters:

contract.deployed().then(function(instance) {
    return instance.addNote(value,"0x092f90acAbb3b23Aded64D59FB6f6Be97615476b");
.then(function(result) {
.catch(function(error) {

I'm getting this error:

Error: invalid address
at inputAddressFormatter (/Desktop/Server/node_modules/truffle-contract/node_modules/web3/lib/web3/formatters.js:274:11)

Also when I'm adding the last parameter:

    from: "0x092f90acAbb3b23Aded64D59FB6f6Be97615476b",
    gas: 1000000

then the error is:

TypeError: Cannot read property 'constructor' of undefined
at /Desktop/Server/node_modules/truffle-contract/contract.js:96:1

What's the problem?

  • are you using truffle ?, can you ad a larger output of the error ? Did you specify a sending address ? the one that you use to send the transaction as the function addNote ? Aug 8, 2018 at 12:40
  • yes, truffle, im edited questions with more details
    – Pawelo
    Aug 8, 2018 at 13:12
  • please post where are you calling constructor that resulted in this error Cannot read property 'constructor' of undefined and it is clear that the invalid address error is gone when adding the fromattribute. Aug 8, 2018 at 13:28
  • an address internally is an array of 20 bytes. A string internally is prefixed with its length, and then the string data follows. String contains Unicode encoded data, while the address contains pure bytes. Both types are completely incompatible.
    – Nulik
    Aug 8, 2018 at 13:29
  • @Nulik, it is true. but that would be something in solidity, not in javascript. so I presume web3 does the conversion and type verifications automatically. Aug 8, 2018 at 13:31

1 Answer 1


An address is a 20-byte hex number, so you shall not send it as a string. Try:

return instance.addNote(value, 0x092f90acAbb3b23Aded64D59FB6f6Be97615476b);

UPDATE: The problem is not related to the address stringification. Please read below.

The confusing part in your specific example is that you're getting an error which misleads you to believe there's something wrong with the function function addNote(uint _value, address _owner). However, the error is about the invalidity of your web3.eth.defaultAccount address, that is, where are your contract calls executed from.

Right after compiling and migrating your contracts, do this:

web3.eth.defaultAccount = web3.eth.accounts[0];
  • it doesnt work,
    – Pawelo
    Aug 8, 2018 at 13:05
  • Recheck the answer :) I found the issue, eventually. Aug 8, 2018 at 13:36
  • Now i did this and still error Error: invalid at inputAddressFormatter. Its about server address not that i'm passing to function?
    – Pawelo
    Aug 9, 2018 at 9:17
  • You shouldn't have that error if you're using truffle develop and follow my answer above. I'm not sure what server address you're using. Have a look at this thread for further advice. Aug 9, 2018 at 9:32

Your Answer

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

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