> For the complete documentation index, see [llms.txt](https://docs.fira.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fira.money/developers/token-contracts/fira-erc20.md).

# FiraERC20

FiraERC20 is the custom ERC-20 base used by every token in the protocol, providing a built-in reentrancy guard and transfer hooks.

{% hint style="info" %}
**Source:** `src/fira_bonding/erc20/FiraERC20.sol`, `FiraERC20Permit.sol`, `FiraERC20Upg.sol`, `FiraERC20PermitUpg.sol`
{% endhint %}

## Variants

| Contract             | Permit   | Upgradeable         | Used by             |
| -------------------- | -------- | ------------------- | ------------------- |
| `FiraERC20`          | No       | No                  | BT, FiraMarket (LP) |
| `FiraERC20Permit`    | EIP-2612 | No                  | —                   |
| `FiraERC20Upg`       | No       | Yes (Initializable) | —                   |
| `FiraERC20PermitUpg` | EIP-2612 | Yes (Initializable) | FW tokens           |

## Reentrancy guard

A `_reentrancyStatus` slot flips between `_NOT_ENTERED` (1) and `_ENTERED` (2). The `nonReentrant` modifier is available to all contracts that inherit `FiraERC20`. This means `FiraMarket` (which extends `FiraERC20` as its LP token) gets reentrancy protection without extra inheritance.

## Transfer hooks

* `_beforeTokenTransfer` — Virtual, overridden by CT (distributes interest) and FW (enforces pause)
* `_afterTokenTransfer` — Virtual, available for derived contracts

## Permit (EIP-2612)

`FiraERC20Permit` adds gasless approvals via `permit(owner, spender, value, deadline, v, r, s)`. Uses EIP-712 typed data for domain separation. The `DOMAIN_SEPARATOR` is computed at construction time and cached.

## Design decisions

* No `receive` or `fallback` — only contracts that need ETH (FWBase, Router) add `receive()`
* Storage layout matches between upgradeable and non-upgradeable variants


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fira.money/developers/token-contracts/fira-erc20.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
