> 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

Achate um smart contract Solidity e todas as suas dependências em um único arquivo .sol usando Remix ou Hardhat para simplificar a verificação do código-fonte nos exploradores da Chiliz Chain.

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="https://1965943722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEhrIGc5MDk2dYuywMGkB%2Fuploads%2Fgit-blob-38ed0c773cb0692116591b5fd54ec2d7420fc4e4%2FScreenshot%202026-01-09%20at%2015.18.06.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chiliz.com/pt-br/desenvolver/basico/verificar-smart-contract/achatar-smart-contract.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
