Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

To easily flatten a contract using Foundry instead of Remix. #711

@Samuel1-ona

Description

@Samuel1-ona

Proposal

In the documentation, I noticed that when verifying contracts on Klaytnscope, the contracts need to be flattened. It was mentioned that developers can use Remix for this purpose. Therefore, I want to include an easy Foundry and Hardhat command to simplify the process of flattening a large codebase that will be built on the Klaytn blockchain.

To flatten on Foundry

Flattening a large codebase using Foundry is straightforward. Simply run the command below, and Foundry will automatically create a Contract.flattened.sol file in the src directory. This file will contain all the contracts in the codebase that have been flattened. Use the following command:

forge flatten --output src/Contract.flattened.sol src/Contract.sol

To flatten on Hardhat

Hardhat flattening commands are quite similar to Foundry. You create a file called flatten.sol in the src directory and run the Hardhat command below:

npx hardhat flatten contracts/Contract1.sol > Flattened.sol
If you have multiple contracts that are not dependent on each other, you can run this command:

npx hardhat flatten contracts/Contract1.sol contracts/Contract2.sol > Flattened.sol

Screenshot from 2024-05-23 13-20-36

Screenshot from 2024-05-23 13-26-57

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions