Welcome to the thread about Ownable Contracts. Here you can discuss everything about the code and potential problems that you might stumble upon.
when you import the Ownable contract file into another contract file, and deploy, the “Owner” button is displayed. I see no Owner function or getOwner function… what part of the Ownable file is creating the Owner button?
Public state variables have getter functions automatically generated for them so in the example you are referring to, notice the public
keyword is used for the owner
variable.
link to GitHub code in this video is opening code on GitHub from previous video
hope reporting that here is ok, I didn’t found any other way to report it
btw I love the course
Thank you for reporting the faulty link. I have replaced it now. I’m so happy to hear that you are enjoying the course. Good luck and let me know if you find some other error.
It looks like the Ownable.sol file has changed on Github. When I try to compile I get this error.
browser/Ownable.sol:25:14: ParserError: Expected identifier, got 'LParen'
constructor() public {
EDIT: Fixed it by using the code from this commit: https://github.com/OpenZeppelin/openzeppelin-solidity/commit/e60aee61f20d25bffa0a1f651247810a8bc8a660#diff-ff7dca5f7cee2c9e49ab96d5f85d00a0
Code
pragma solidity ^0.4.18;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
when you deploy the kennel contract , the deployment of the dog contract and the ownable contract are deploy by them self because the kennel inherite from them?
Yes you could view it like that. What really happens is that all inherited and imported contracts will be “copy pasted” by the compiler into the main contract. But as users we don’t see that.