I am receiving this error when trying to call the getUsers getter function from the contract below: Invalid number of arguments to Solidity function. Running on Truffle in develop mode.

mapping (address => User) Users;
address[] usersByAddress;

struct User {
    string handle;
    bytes32 city;
    bytes32 state;
    bytes32 country;

function registerNewUser(string handle, bytes32 city, bytes32 state, bytes32 country) returns (bool success) {
    address thisNewAddress = msg.sender;
    if(bytes(Users[msg.sender].handle).length == 0 && bytes(handle).length != 0){
        Users[thisNewAddress].handle = handle;
        Users[thisNewAddress].city = city;
        Users[thisNewAddress].state = state;
        Users[thisNewAddress].country = country;
        return true;
    } else {
        return false;       

function getUsers() view returns (address[]) { return usersByAddress; }

function getUser(address userAddress) view returns (string, bytes32, bytes32, bytes32) {
    return (Users[userAddress].handle, Users[userAddress].city, Users[userAddress].state, Users[userAddress].country);

Let's say you deploy this contract in Truffle develop testnet and get an instance of the object x. I can create a user by sending the transaction x.registerNewUser("Bob123","Orlando","FL","USA"). Then I run x.getUser(web3.eth.accounts[0]) and get the following array:

[ 'Bob123', '0x4f726c616e646f00000000000000000000000000000000000000000000000000', '0x464c000000000000000000000000000000000000000000000000000000000000', '0x5553410000000000000000000000000000000000000000000000000000000000' ]

This is expected since the last 3 elements in the array are type bytes32. I expect x.getUsers or x.getUsers.call() to return an array of one address (my address at web3.eth.accounts[0]) but instead get the invalid Solidity arguments error even though there are no arguments passed into getUsers.

  • Please provide the code where you call getUser Commented Nov 16, 2017 at 4:05
  • I edited the question with the code I use to register a user and to call the getUser and getUsers functions.
    – atc
    Commented Nov 16, 2017 at 4:57
  • 3
    This is definitely a Truffle issue - your code runs sweetly in Remix. There are some issues on the Truffle and web3.js GitHubs about this with suggested solutions - worth trying. Let us know if it helps. Commented Nov 16, 2017 at 7:24
  • 1
    Thanks @benjaminion for those links, deleting the artifacts in /build prevents the error from showing up.
    – atc
    Commented Nov 16, 2017 at 19:31

1 Answer 1


try this one:

x.getUser.call(web3.eth.accounts[0],{from: 'YOUR ADDRESS'}, function (error, result) {
    console.log('error ' + error);
    console.log('result ' + result);
  • 1
    There aren't any issues with getting the getUser() function to work. As stated in my question it's the getUsers(). The only way I could get it to work was what @benjaminion suggested is delete the artifacts in the /build, migrate --reset, and new artifacts will be written in /build which then prevents errors from showing up when you call getUsers().
    – atc
    Commented Nov 18, 2017 at 5:17

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.