I'm following cryptozombies solidity tutorial. In lesson 2, chapter 11 it explains how to create an interface for CryptoKitties as follows:
contract KittyInterface {
function getKitty(uint256 _id) external view returns (
bool isGestating,
bool isReady,
uint256 cooldownIndex,
uint256 nextActionAt,
uint256 siringWithId,
uint256 birthTime,
uint256 matronId,
uint256 sireId,
uint256 generation,
uint256 genes
);
}
then it initializes it in a contract:
contract ZombieFeeding is ZombieFactory {
address ckAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;
KittyInterface kittyContract = KittyInterface(ckAddress); // this initialization is what I don't get
function feedAndMultiply(uint _zombieId, uint _targetDna) public {
require(msg.sender == zombieToOwner[_zombieId]);
Zombie storage myZombie = zombies[_zombieId];
_targetDna = _targetDna % dnaModulus;
uint newDna = (myZombie.dna + _targetDna) / 2;
_createZombie("NoName", newDna);
}
}
I don't get how the interface can be initialized using when no constructor is defined in KittyInterface.
I saw that usually the keyword interface is used to define interfaces (instead of contract) and I was thinking maybe the compiler knows that an interface can be initialized using an adress, but that's is not the case here.
If someone could explain how this works, it would be wonderful.