> 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/ko/gaebal/gibon/seumateu-keonteulaekteu-geomjeung/keonteulaekteu-pyeongtanhwa.md).

# 스마트 컨트랙트 평탄화

스마트 컨트랙트 평탄화는 메인 컨트랙트와 모든 의존성(인터페이스, 라이브러리, 상속된 컨트랙트)을 하나의 독립적인 `.sol` 파일로 합치는 과정입니다. 이를 통해 배포된 컨트랙트를 훨씬 쉽게 검증할 수 있습니다.

{% hint style="info" %}
컨트랙트를 배포하기 위해 평탄화할 필요는 없습니다.

평탄화는 주로 탐색기에서 소스 코드를 검증하기 위한 배포 후 단계입니다.
{% endhint %}

Chiliz Chain은 EVM 호환 블록체인이므로 컨트랙트를 평탄화하는 여러 도구를 사용할 수 있습니다.

{% hint style="info" %}
원본 파일에서 배포한 후 평탄화하여 전체 컨트랙트를 검증하는 경우, 컴파일 설정이 변경되지 않았는지 확인해야 합니다.

그렇지 않으면 "Bytecode mismatch" 유형의 오류가 발생하여 검증이 실패할 수 있습니다.
{% endhint %}

## Remix IDE를 이용한 평탄화

파일 탐색기에서 메인 컨트랙트를 마우스 오른쪽 버튼으로 클릭하고 메뉴에서 "Flatten"을 선택합니다.

Remix는 폴더에 `CONTRACT_flattened.sol` 컨트랙트를 생성합니다.

## Hardhat을 이용한 평탄화

워크플로에 맞게 다음 명령을 수정하세요.

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

{% hint style="warning" %}
평탄화된 컨트랙트는 수천 줄에 달할 수 있어 실제 개발 및 유지보수에는 매우 불편합니다.

배포된 컨트랙트를 검증할 때처럼 필요한 경우에만 생성해야 합니다.
{% 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, and the optional `goal` query parameter:

```
GET https://docs.chiliz.com/ko/gaebal/gibon/seumateu-keonteulaekteu-geomjeung/keonteulaekteu-pyeongtanhwa.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.
