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

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

Open
Samuel1-ona opened this issue May 23, 2024 · 0 comments
Open

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

Samuel1-ona opened this issue May 23, 2024 · 0 comments

Comments

@Samuel1-ona
Copy link

Samuel1-ona commented May 23, 2024

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant