I am just struggling to understand why the constructor is done like it is and what is it doing?
I am trying to implement something similar as am looking to find the address of the contract, called DiceGame in this example.
Here, the constructor is asking for an address called diceGameAddress
which will, hopefully, will be deployed DiceGame
contract.
Now the line diceGame = DiceGame(diceGameAddress)
is actually creating an instance of this deployed contract in this contract to be used later.
And finally, the address is being updated in the dice
variable.
Your constructor should be
contract RidgeRoll is Ownable {
DiceGame public diceGame;
constructor(DiceGame diceGameAddress) {
diceGame = diceGameAddress;
}
}
then you can the functions of DiceGame inside RidgeRoll like this :
function use() public {
diceGame.functionToUse();
}