> 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/pt-br/desenvolver/basico/verificar-smart-contract/achatar-smart-contract.md).

# Achatar um Smart Contract

Achatar um smart contract é o processo de combinar o contrato principal com todas as suas dependências (interfaces, bibliotecas, contratos herdados) em um único arquivo `.sol` independente. Isso facilita muito a validação do contrato implantado.

{% hint style="info" %}
Você não precisa achatar seu contrato para implantá-lo.

O achatamento é principalmente uma etapa pós-implantação usada para verificar seu código-fonte em um explorer.
{% endhint %}

Como a Chiliz Chain é um blockchain compatível com EVM, há várias ferramentas disponíveis para achatar um contrato.

{% hint style="info" %}
Se você implantou a partir dos arquivos originais e depois os achatou para verificar o contrato completo, deve garantir que nada mude nas configurações de compilação.

Caso contrário, você corre o risco de obter um erro do tipo "Bytecode mismatch" e a verificação falhará.
{% endhint %}

## Achatar usando o Remix IDE

No File Explorer, clique com o botão direito no seu contrato principal e escolha "Flatten" no menu.

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

O Remix irá gerar um contrato `CONTRACT_flattened.sol` na sua pasta.

## Achatar usando Hardhat

Adapte a linha a seguir ao seu fluxo de trabalho:

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

{% hint style="warning" %}
Como um contrato achatado pode ter milhares de linhas, eles são péssimos para desenvolvimento e manutenção reais.

Eles devem ser gerados apenas quando necessário, por exemplo, ao verificar o contrato implantado.
{% 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/pt-br/desenvolver/basico/verificar-smart-contract/achatar-smart-contract.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.
