# Access control

OpenZeppelin's Access Control Library:

OpenZeppelin's Access Control library is a powerful tool for managing authorizations and permissions in Ethereum smart contracts. It provides functionality to restrict access to certain parts of the contract only to specific users or predefined roles.

Example:

```solidity
// contracts/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";

contract MyContract is Ownable {
    function normalThing() public {
        // anyone can call this normalThing()
    }

    function specialThing() public onlyOwner {
        // only the owner can call specialThing()!
    }
}
```

**Let's explain how it works**

<mark style="color:blue;">Importing the library</mark>

In the code above, the Access Control library is imported using the statement `import "@openzeppelin/contracts/access/Ownable.sol";`. This means that Access Control functionality is available in the `MyContract` contract.

<mark style="color:blue;">Inheriting the Ownable class</mark>

The `MyContract` contract inherits from the `Ownable` class provided by the Access Control library. This means that `MyContract` will have access to the access control functionality provided by `Ownable`.

<mark style="color:blue;">Using access control functions</mark>

In `MyContract`, you can see two functions: `normalThing()` and `specialThing()`. Let's see how they are affected by access control functions:

1. `normalThing()`: This function has no specific access restrictions. This means that anyone can call this function without any limitations.
2. `specialThing()`: This function is marked with the `onlyOwner` modifier, provided by the `Ownable` class. This modifier ensures that only the address that deploys the contract (the owner) can call this function. In this way, access to `specialThing()` is restricted to contract owners only.

> <mark style="color:blue;">**Conclusion**</mark>
>
> OpenZeppelin's Access Control library provides a practical solution for managing permissions and roles in Ethereum contracts. By inheriting from the `Ownable` class and using the `onlyOwner` modifier, you can easily restrict access to certain parts of your contract to authorized users. This enhances security and enables you to implement effective governance features in your smart contracts.
