This article is geared towards those that are beginning to interact with smart contracts in ethereum.
I’ve been through this a few times — and for those just starting in the space — this can somewhat be an annoying process — especially when trying to get verified on Etherscan.io
Typically your files will be in a combination of subfolders — and this article is meant to give a more detailed overview for those that want to get their contracts source code verified. We will do this from scratch for those not familiar with using npm and the terminal.
We will be using the POA Solidity Flattener found here (clone this to your local directory): https://github.com/poanetwork/solidity-flattener
First thing first is install NPM here.
To use some reference files — we can use some token contracts from openzepplin who provides an awesome collection of free smart contracts.
Open in Github Desktop, download the zip or clone the repo — whatever works for ya (I personally like Github Desktop).
We can use contracts/token/ERC20/ERC20Mintable.sol — This is a standard mintable token.
See how it starts with those two imports? Those are referencing other contracts in the repo. When it comes time to verify your source code, easy deployment of small contracts etc — what you want is a flattened file which holds all the imports in a single contract.
Open up your terminal and cd into your poa network folder (soldity-flattener) and then enter npm install.
You can now simply enter ‘npm start’ and add the file name of your smart contract (.sol file)
See that out folder…
Boom — flat file baby