> For the complete documentation index, see [llms.txt](https://docs.rei.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rei.network/developer/system-contracts/contractfee.md).

# ContractFee

## Contents

## Globals

| Var       | Type                        |
| --------- | --------------------------- |
| feeOf     | mapping(address => uint256) |
| creatorOf | mapping(address => address) |

## Functions

### generateAddress

Generate contract address.

**Declaration:**

```solidity
  function generateAddress(
    address from,
    uint256 nonce
  ) public returns (address)
```

**Modifiers:** No modifiers

**Args:**

| Arg     | Type    | Description     |
| ------- | ------- | --------------- |
| `from`  | address | Creator address |
| `nonce` | uint256 | Creator nonce   |

### generateAddress2

Generate contract address(create2).

**Declaration:**

```solidity
  function generateAddress2(
    address from,
    bytes32 salt,
    bytes32 codeHash
  ) public returns (address)
```

**Modifiers:** No modifiers

**Args:**

| Arg        | Type    | Description                                                             |
| ---------- | ------- | ----------------------------------------------------------------------- |
| `from`     | address | Creator address                                                         |
| `salt`     | bytes32 | Salt                                                                    |
| `codeHash` | bytes32 | Deploy code hash, notice: this is not the same as the account code hash |

### register

Register the contract creator.

**Declaration:**

```solidity
  function register(
    address parent,
    bool[] flags,
    uint256[] nonces,
    struct Create2Info[] infos
  ) external
```

**Modifiers:** No modifiers

**Args:**

| Arg      | Type                  | Description                                                                                                                                            |
| -------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `parent` | address               | Root creator address                                                                                                                                   |
| `flags`  | bool\[]               | A list of flags, if the flag is true, it means `create` and load a nonce from nonces, otherwise it means `create2` and load a `Create2Info` from infos |
| `nonces` | uint256\[]            | A list of nonces                                                                                                                                       |
| `infos`  | struct Create2Info\[] | A list of `Create2Info`                                                                                                                                |

### setFee

Set contract fee. The contract fee can be set only when the sender is the creator of the contract.

**Declaration:**

```solidity
  function setFee(
    address contractAddress,
    uint256 fee
  ) external
```

**Modifiers:** No modifiers

**Args:**

| Arg               | Type    | Description             |
| ----------------- | ------- | ----------------------- |
| `contractAddress` | address | Target contract address |
| `fee`             | uint256 | Contract fee            |

## Events

### Register

Registration event, emit when someone registers their contract.

#### Params:

| Param    | Type    | Indexed | Description      |
| -------- | ------- | :-----: | ---------------- |
| `parent` | address |         | Creator          |
| `child`  | address |         | Contract address |


---

# 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 dynamically by asking a question.

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

```
GET https://docs.rei.network/developer/system-contracts/contractfee.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
