# ERC20Facet

[Git Source](https://github.com/Forgenie/diamond-foundry/blob/e69a7af04e0636b77b9dd15df62c58172ec045da/src/facets/erc20/ERC20Facet.sol)

**Inherits:** IERC20, ERC20Base, Facet

## Functions

### ERC20\_init

```solidity
function ERC20_init(string memory name_, string memory symbol_, uint8 decimals_) external onlyInitializing;
```

### name

*Returns the name of the token.*

```solidity
function name() external view returns (string memory);
```

### symbol

*Returns the symbol of the token.*

```solidity
function symbol() external view returns (string memory);
```

### decimals

*Returns the decimals places of the token.*

```solidity
function decimals() external view returns (uint8);
```

### transfer

Moves an amount of tokens from the caller's account to another account.

```solidity
function transfer(address to, uint256 amount) external returns (bool);
```

**Parameters**

| Name     | Type      | Description                                      |
| -------- | --------- | ------------------------------------------------ |
| `to`     | `address` | The account where the tokens are transferred to. |
| `amount` | `uint256` | The number of tokens transferred.                |

**Returns**

| Name     | Type   | Description                                               |
| -------- | ------ | --------------------------------------------------------- |
| `<none>` | `bool` | Boolean value indicating whether the operation succeeded. |

### approve

Sets an amount as the allowance of spender over the caller's tokens.

```solidity
function approve(address spender, uint256 amount) external returns (bool);
```

**Parameters**

| Name      | Type      | Description                                         |
| --------- | --------- | --------------------------------------------------- |
| `spender` | `address` | The account that is allowed to transfer the tokens. |
| `amount`  | `uint256` | The number of tokens that are approved.             |

**Returns**

| Name     | Type   | Description                                            |
| -------- | ------ | ------------------------------------------------------ |
| `<none>` | `bool` | bool value indicating whether the operation succeeded. |

### transferFrom

Transferrs an amount of tokens from an account to other using the allowance mechanism.

*Amount is deducted from the caller's allowance.*

```solidity
function transferFrom(address from, address to, uint256 amount) external returns (bool);
```

**Parameters**

| Name     | Type      | Description                                        |
| -------- | --------- | -------------------------------------------------- |
| `from`   | `address` | The account where the tokens are transferred from. |
| `to`     | `address` | The account where the tokens are transferred to.   |
| `amount` | `uint256` | The number of tokens transferred.                  |

**Returns**

| Name     | Type   | Description                                            |
| -------- | ------ | ------------------------------------------------------ |
| `<none>` | `bool` | bool value indicating whether the operation succeeded. |

### allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner.

*This value changes when {approve} or {transferFrom} are called and is zero by default.*

```solidity
function allowance(address owner, address spender) external view returns (uint256);
```

**Parameters**

| Name      | Type      | Description                                         |
| --------- | --------- | --------------------------------------------------- |
| `owner`   | `address` | The account that owns the tokens.                   |
| `spender` | `address` | The account that is allowed to transfer the tokens. |

### totalSupply

Returns the amount of tokens in existence.

```solidity
function totalSupply() external view returns (uint256);
```

### balanceOf

Returns the amount of tokens owned by an account.

```solidity
function balanceOf(address account) external view returns (uint256);
```

**Parameters**

| Name      | Type      | Description                        |
| --------- | --------- | ---------------------------------- |
| `account` | `address` | The account to get the balance of. |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forgenie.com/specification/diamond-foundry/facets/erc20facet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
