> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/jp/kaihatsu/kihon/smart-contract-verify/flatten.md).

# Smart Contract を flatten する

smart contract のフラット化とは、メインの contract をそのすべての依存関係（インターフェース、ライブラリ、継承された contract）と組み合わせて、単一のスタンドアロンな `.sol` ファイルにまとめるプロセスです。これにより、deploy された contract の検証がはるかに容易になります。

{% hint style="info" %}
contract を deploy するためにフラット化する必要はありません。

フラット化は主に、エクスプローラー上でソースコードを verify するための deploy 後のステップです。
{% endhint %}

Chiliz Chain は EVM 互換のブロックチェーンであるため、contract をフラット化するためのツールがいくつか用意されています。

{% hint style="info" %}
元のファイルから deploy した後、contract 全体を verify するためにそれらをフラット化する場合は、コンパイル設定に何も変更がないことを確認する必要があります。

そうしないと、「Bytecode mismatch」のようなエラーが発生し、verify に失敗するおそれがあります。
{% endhint %}

## Remix IDE を使ってフラット化する

File Explorer でメインの contract を右クリックし、メニューから「Flatten」を選択します。

<figure><img src="/files/MaVISsU3gQHRllRg1yjo" alt="" width="375"><figcaption></figcaption></figure>

Remix はフォルダー内に `CONTRACT_flattened.sol` という contract を生成します。

## Hardhat を使ってフラット化する

次の行を自分のワークフローに合わせて調整してください。

```bash
npx hardhat flatten contracts/MyContract.sol > Flattened.sol
```

{% hint style="warning" %}
フラット化された contract は数千行に及ぶことがあるため、実際の開発やメンテナンスには非常に不向きです。

それらは必要なとき、たとえば deploy された contract を verify するときにのみ生成すべきです。
{% endhint %}


---

# 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:

```
GET https://docs.chiliz.com/jp/kaihatsu/kihon/smart-contract-verify/flatten.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.
