Creo una matriz de estructura y la asigno a una dirección:
contract MyContract
{
struct something {
bytes32 test1;
bytes32 test2;
bytes32 test3;
}
mapping (address => Something[]) public stuff;
}
En la aplicación, trato de usar la función getter creada automáticamente de esta manera:
let sender = web3.eth.accounts[0];
console.log(contract.stuff(sender))
Devuelve este 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)
¿Qué necesita la función getter de "cosas"? Si cambio el mapeo a esto:
mapping (address => Something) public stuff;
Puedo llamarlo bien. ¿Necesito pasar la prueba 1, la prueba 2 y la prueba 3?
Tienes que agregar índice de cosas
console.log(contract.stuff(sender,0))
Lo siento, todavía soy nuevo en esto, eché un vistazo a la ABI y las entradas estaban allí:
{
"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"
},