I thinking about this owner modifier. The constructor is saving the address of the owner which is taken from the wallet (we can use our own or customer/employer), and then after deploy nobody will be able to change the value of the owner variable in the constructor, won’t they? That would mean if I as a owner will lose the account with the ownership address or I would die, without leaving my keys somewhere, nobody will be able to do modify the contract?
constructor() public {
owner = msg.sender;
}
And just to confirm, code below means: // ownerToAnimals[msg.sender] is pointing which array of animals to use what is defined by msg.sender, then which animal to return by id, and the last returning string which the name of the animal; is my reasoning right?
return ownerToAnimals[msg.sender][_id].name;
I have tried to return whole array, but it doesn’t work, it seems that I need to use some expansions to run it
function getArrayOfAnimals() public returns (Animal[] memory) {
return ownerToAnimals[msg.sender];
}
browser/Animal.sol:38:50: TypeError: This type is only supported in the new experimental ABI encoder. Use “pragma experimental ABIEncoderV2;” to enable the feature.
function getArrayOfAnimals() public returns (Animal[] memory) {
^-------------^
I have used “pragma experimental ABIEncoderV2;” below the “pragma solidity 0.5.1;” and the output was like this (instead AnimalType I got uint8, I don’t know why):
{
"0": "tuple(string,uint256,uint8)[]: Mela,2,0,Zula,3,0,Kora,5,0"
}