> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inco.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting up the Contract

> Learn how to set up the basic structure of a confidential ERC20 token

## Import Required Libraries

First, we need to import the necessary contracts and libraries:

```Solidity theme={null}
pragma solidity ^0.8.28;

import {inco, e, ebool, euint256} from "@inco/lightning/src/Lib.sol";
import {asBool} from "@inco/lightning/src/shared/TypeUtils.sol";
import {DecryptionAttestation} from "@inco/lightning/src/lightning-parts/DecryptionAttester.types.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
```

## Contract Definition

Our confidential ERC20 contract inherits from `Ownable2Step`, which provides secure ownership management:

```Solidity theme={null}
contract ConfidentialERC20 is Ownable2Step {
    // Contract implementation will go here
}
```

<Note>
  The `Ownable2Step` contract from OpenZeppelin sets the owner in the constructor, allowing only the owner to view all users' balances.
</Note>

## State Variables

We need to define our state variables, including encrypted balances and allowances:

```Solidity theme={null}
euint256 public totalSupply;
string public _name;
string public _symbol;
uint8 public constant decimals = 18;

// Mappings for balances and allowances
mapping(address => euint256) internal balances;
mapping(address => mapping(address => euint256)) internal allowances;
```

<Note>
  Notice that `balances`, `allowances`, and `totalSupply` use the `euint256` type for encrypted storage.
</Note>

## Events

Define the standard ERC20 events plus custom events for minting:

```Solidity theme={null}
// Errors
error InsufficientFees();

// Events for Transfer, Approval, and Mint
event Transfer(address indexed from, address indexed to, euint256 amount);
event Approval(
    address indexed owner,
    address indexed spender,
    euint256 amount
);
event Mint(address indexed to, uint256 amount);
event EncryptedMint(address indexed to, euint256 amount);
```

## Understanding the Structure

<Card title="Encrypted Types" icon="lock">
  `euint256` is used for encrypted integers, ensuring balance privacy
</Card>

<Card title="Access Control" icon="user-shield">
  `Ownable2Step` provides secure ownership management
</Card>

<Card title="Events" icon="bell">
  Events enable tracking transfers and approvals without revealing amounts
</Card>

## Next Steps

<p title="Defining Functions" icon="code" href="/tutorials/confidential-token/hardhat/contract-functions">
  Continue to learn how to implement the core token functionality
</p>
