0

I am trying out the Truffle Pet Shop tutorial and it seems to be working all well except for a small issue.

My solidity function getAdopters() returns an address[16]

function getAdopters() public view returns (address[16]) {
  return adopters;
}

and on my client side I use the following function (as per the tutorial)

App.contracts.Adoption.deployed().then(function(instance) {
  adoptionInstance = instance;
  return adoptionInstance.getAdopters.call();
}).then(function(adopters) {
  for(i = 0; i < adopters.length; i++) {
    if(adopters[i] !== '0x0000000000000000000000000000000000000000') {
      $('.panel-pet').eq(i).find('button').text('Success').attr('disabled', true);
    }
  }

}).catch(function(error) {
  console.error(err.message);
});

My issue lies on what's returned by the getAdopters call. The empty address is not '0x0000000000000000000000000000000000000000' but 0x0 for the first address and 0x for the rest of them.

enter image description here

Of course I change the loop to check for either of them to see if the address is empty.

But why does it not return a proper standardised empty address for all of them ? Is this the correct way to check for empty addresses ?

0

The issue was solved by running the migrations again. It seems that the first time I ran the migrations they were not run correctly.

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.