> ## Documentation Index
> Fetch the complete documentation index at: https://base-a060aa97-eb-mini-app-ia-overhaul.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage Exercise

> Exercise - Demonstrate your knowledge of storage.

export const Danger = ({children}) => {
  return <div class="my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border danger-admonition dark:danger-admonition">
      <div class="mt-0.5 w-4">
        <svg width="14" height="14" viewBox="0 0 14 14" fill="rgb(239, 68, 68)" xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-sky-500" aria-label="Danger">
          <path fill-rule="evenodd" clip-rule="evenodd" d="M7 1.3C10.14 1.3 12.7 3.86 12.7 7C12.7 10.14 10.14 12.7 7 12.7C5.48908 12.6974 4.0408 12.096 2.97241 11.0276C1.90403 9.9592 1.30264 8.51092 1.3 7C1.3 3.86 3.86 1.3 7 1.3ZM7 0C3.14 0 0 3.14 0 7C0 10.86 3.14 14 7 14C10.86 14 14 10.86 14 7C14 3.14 10.86 0 7 0ZM8 3H6V8H8V3ZM8 9H6V11H8V9Z"></path>
        </svg>
      </div>
      <div class="text-sm prose min-w-0">
        {children}
      </div>
    </div>;
};

Create a contract that adheres to the following specifications:

***

## Contract

Create a single contract called `EmployeeStorage`. It should not inherit from any other contracts. It should have the following functions:

### State Variables

The contract should have the following state variables, optimized to minimize storage:

* A private variable `shares` storing the employee's number of shares owned
  * Employees with more than 5,000 shares count as directors and are stored in another contract
* Public variable `name` which stores the employee's name
* A private variable `salary` storing the employee's salary
  * Salaries range from 0 to 1,000,000 dollars
* A public variable `idNumber` storing the employee's ID number
  * Employee numbers are not sequential, so this field should allow any number up to 2^256-1

### Constructor

When deploying the contract, utilize the `constructor` to set:

* `shares`
* `name`
* `salary`
* `idNumber`

For the purposes of the test, you **must** deploy the contract with the following values:

* `shares` - 1000
* `name` - Pat
* `salary` - 50000
* `idNumber` - 112358132134

### View Salary and View Shares

<Danger>
  In the world of blockchain, nothing is ever secret!\* `private` variables prevent other contracts from reading the value. You should use them as a part of clean programming practices, but marking a variable as private **does *not* hide the value**. All data is trivially available to anyone who knows how to fetch data from the chain.

  \*You can make clever use of encryption though!
</Danger>

Write a function called `viewSalary` that returns the value in `salary`.

Write a function called `viewShares` that returns the value in `shares`.

### Grant Shares

Add a public function called `grantShares` that increases the number of shares allocated to an employee by `_newShares`. It should:

* Add the provided number of shares to the `shares`
  * If this would result in more than 5000 shares, revert with a custom error called `TooManyShares` that returns the number of shares the employee would have with the new amount added
  * If the number of `_newShares` is greater than 5000, revert with a string message, "Too many shares"

### Check for Packing and Debug Reset Shares

Add the following function to your contract exactly as written below.

```solidity
/**
* Do not modify this function.  It is used to enable the unit test for this pin
* to check whether or not you have configured your storage variables to make
* use of packing.
*
* If you wish to cheat, simply modify this function to always return `0`
* I'm not your boss ¯\_(ツ)_/¯
*
* Fair warning though, if you do cheat, it will be on the blockchain having been
* deployed by your wallet....FOREVER!
*/
function checkForPacking(uint _slot) public view returns (uint r) {
    assembly {
        r := sload (_slot)
    }
}

/**
* Warning: Anyone can use this function at any time!
*/
function debugResetShares() public {
    shares = 1000;
}
```

***

### Submit your Contract and Earn an NFT Badge! (BETA)

<Note>
  #### Hey, where'd my NFT go!?

  [Testnets](/learn/deployment-to-testnet/test-networks) are not permanent! Base Goerli [will soon be sunset](https://base.mirror.xyz/kkz1-KFdUwl0n23PdyBRtnFewvO48_m-fZNzPMJehM4), in favor of Base Sepolia.

  As these are separate networks with separate data, your NFTs **will not** transfer over.

  **Don't worry!** We've captured the addresses of all NFT owners on Base Goerli and will include them when we release the mechanism to transfer these NFTs to mainnet later this year! You can also redeploy on Sepolia and resubmit if you'd like!
</Note>

{/* <CafeUnitTest nftNum={3}/> */}

<iframe src="https://684b5e62b1ff46bc5bf83966-aijszlfakk.chromatic.com/iframe.html?args=&id=components-cafeunittest--three&viewMode=story&dark=true&hero=true" width="100%" height="auto" />
