0

I create a struct array and map it to an address:

contract MyContract
{
    struct something {
        bytes32 test1;
        bytes32 test2;
        bytes32 test3;
    }

    mapping (address => Something[]) public stuff;
}

In the app I try to use the automatically created getter function like this:

let sender = web3.eth.accounts[0];

console.log(contract.stuff(sender))

It kicks back this error:

inpage.js:14246 Uncaught Error: Invalid number of arguments to Solidity function
    at Object.InvalidNumberOfSolidityArgs (inpage.js:14246)
    at c.validateArgs (inpage.js:14246)
    at c.toPayload (inpage.js:14246)
    at c.call (inpage.js:14246)
    at c.execute (inpage.js:14246)
    at addStuff (index.js:30)
    at HTMLButtonElement.onclick ((index):53)

What does the "stuff" getter function need? If i change the mapping to this:

mapping (address => Something) public stuff;

I can call it just fine. Do I need to pass it test1, test2, and test3?

0

You have to add index of stuff

console.log(contract.stuff(sender,0))

0

Sorry im still new to this, i took a look at the ABI and the inputs were right there:

{
  "constant": true,
  "inputs": [
    {
      "name": "",
      "type": "address"
    },
    {
      "name": "",
      "type": "uint256"
    }
  ],
  "name": "stuff",
  "outputs": [
    {
      "name": "test1",
      "type": "bytes32"
    },
    {
      "name": "test2",
      "type": "bytes32"
    },
    {
      "name": "test3",
      "type": "bytes32"
    }
  ],
  "payable": false,
  "stateMutability": "view",
  "type": "function"
},

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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