I'm trying to interact with this contract via web3.js.
Something like this answer seems to be the right path to take, but I can't figure out how to implement that logic in my contract.
When getAdopters() is called, I see the following error in my browser's console:
invalid solidity type!: tuple[16]
Here's the code where getAdopters() is called:
markAdopted: function(owners, account) {
var adoptionInstance;
App.contracts.Adoption.deployed().then(function(instance) {
adoptionInstance = instance;
return adoptionInstance.getAdopters.call();
}).then(function(owners) {
for (i = 0; i < owners.length; i++) {
if (owners[i] !== '0x0000000000000000000000000000000000000000') {
$('.panel-pet').eq(i).find('button').text('Success').attr('disabled', true);
var loc = document.getElementById('owned-by');
loc.innerHTML += owners[i];
console.log(valueOf(owners[0]));
}
}
}).catch(function(err) {
console.log(err.message);
});
},
Ultimately, how can I return the fields of the struct as separate return variables, and then access them using web3.js?
getAdopters()function such that web3js receives it as an array? if you can just help me with that, I'd be glad to accept your answer – rustyshackleford Feb 17 '18 at 23:13markAdopted()function in my js file? – rustyshackleford Feb 18 '18 at 00:13ownersis being returned as an empty array. In the console, I seeCannot convert undefined or null to object. I've edited my question with my updated js code. What do you think I'm doing wrong here? – rustyshackleford Feb 18 '18 at 00:50markAdopted()function? – rustyshackleford Feb 18 '18 at 02:14