# Contract 1: GameToken (ERC20)

**Purpose**: ERC20 token serving as the native game currency

**Key Features**:

* Role-based access control (MINTER\_ROLE, BURNER\_ROLE)
* Genesis mint of 1,000,000 tokens
* Controlled minting/burning for game economy

```solidity
contract GameToken is ERC20, AccessControl {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
```

**What's happening here?**

* Creates a custom ERC20 token that inherits from OpenZeppelin's ERC20 and AccessControl
* Defines two roles using `keccak256` hashing: MINTER\_ROLE and BURNER\_ROLE
* These roles control who can create or destroy tokens

```solidity
constructor() ERC20("GameFi Token", "GAME") {
    _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    _grantRole(MINTER_ROLE, msg.sender);
    
    // Genesis mint
    _mint(msg.sender, 1000000 * 10**18);
}
```

**What's happening here?**

* Constructor sets token name to "GameFi Token" and symbol to "GAME"
* Gives the deployer admin and minter roles
* Mints 1 million initial tokens (multiplied by 10^18 for 18 decimal places)

```solidity
function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
    _mint(to, amount);
}

function burn(address from, uint256 amount) external onlyRole(BURNER_ROLE) {
    _burn(from, amount);
}
```

**What's happening here?**

* `mint`: Only addresses with MINTER\_ROLE can create new tokens
* `burn`: Only addresses with BURNER\_ROLE can destroy tokens
* This creates a controlled token economy where supply can be managed
