Skip to content

ElefanteServices/SAFEcontract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project: Ownable Smart Contract (OpenZeppelin)

This repository contains an implementation of OpenZeppelin's Ownable.sol abstract contract. This contract provides a basic access control mechanism, allowing for a single owner with exclusive privileges for certain functions.

Author

Alexandre Azeredo

  • Focus: Senior positions in Cryptocurrency and Blockchain sectors, including Crypto Trading, Bitcoin Banking, Bitcoin-related Companies, DeFi Trading, Blockchain Lead, and Product Lead roles.
  • Key Experience: Deed, Zoop.
  • Skills & Attributes: Empathy, extensive international experience (worked and lived worldwide), fluent in English and Portuguese, enjoys interacting with people from diverse cultures.
  • Professional Profile Style: Banking-style resume format preferred.
  • ResearchGate Profile: https://www.researchgate.net/profile/Alexandre-Azeredo (Note: Access may be subject to network restrictions or captchas)

Contract Overview

The Ownable.sol contract is designed to be inherited by other contracts that require an ownership-based access control system. Key features include:

  • Single Owner: The contract is controlled by a single owner, initially set to the deployer's address.
  • onlyOwner Modifier: Restricts function execution to the contract owner.
  • Ownership Transfer: Allows the current owner to transfer ownership to a new account.
  • Renounce Ownership: Allows the current owner to relinquish ownership, leaving the contract without an owner.
  • Events: Emits OwnershipTransferred upon any change in ownership.
  • Error Handling: Includes specific errors for unauthorized access (OwnableUnauthorizedAccount) and invalid owner addresses (OwnableInvalidOwner).

Files

  • Ownable.sol: The main abstract contract implementing the ownership logic.
  • utils/Context.sol: A dependency from OpenZeppelin, providing context information like msg.sender.
  • contract_specifications.md: Detailed documentation of the Ownable.sol contract's features and behavior.

Usage

To use this contract, inherit from Ownable in your own smart contract and utilize the onlyOwner modifier for functions that require restricted access.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "./Ownable.sol";

contract MyContract is Ownable {
    uint256 public myValue;

    constructor(address initialOwner) Ownable(initialOwner) {
        // Constructor logic
    }

    function setValue(uint256 newValue) public onlyOwner {
        myValue = newValue;
    }
}

Setup & Compilation

To compile this contract, you will need a Solidity compiler (e.g., solc) compatible with version ^0.8.20.

  1. Ensure solc is installed.
  2. Navigate to the smart-contract-ownable directory.
  3. Compile the contract (example using solc):
    solc --base-path . --include-path ./node_modules --abi --bin Ownable.sol -o build --overwrite
    # (Adjust paths and options as needed, especially if using a framework like Hardhat or Truffle)

This project provides the foundational Ownable.sol and its Context.sol dependency. For a full development environment, consider using tools like Hardhat or Truffle, which handle dependencies and compilation more robustly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors