I was having trouble verifying my contracts on the Matic blockscout explorer when they were using included files such as the openzepplin libraries.
I found that I was not having good luck with the truffle-flattener, so I went out seeking something else.
I wound up using: https://github.com/DaveAppleton/SolidityFlattery -- which I found from this openzeppelin thread.
You'll need to install golang and configure your gopath.
Then clone the repo, compile the source, and move the binary somewhere in your path.
cd $GOPATH/src
mkdir -p github.com/DaveAppleton
cd github.com/DaveAppleton/
// You may need to use https:// to clone depending on your setup.
git clone [email protected]:DaveAppleton/SolidityFlattery.git
cd SolidityFlattery/
go build
./SolidityFlattery
sudo mv SolidityFlattery /usr/bin/
Check that it works:
$ SolidityFlattery
Solididy File Flattener 1.20 (c) David Appleton 2018 to 2020 and beyond
contact : [email protected]
https://github.com/DaveAppleton/SolidityFlattery
released under Apache 2.0 licence
Usage of ./SolidityFlattery:
-input string
base file to flatten
-output string
output file
And then I flattened like:
SolidityFlattery -input contracts/boom.sol -output contracts/flatboom
You'll want to have different contract names in truffle or it'll complain, like: contract NameHere
. And then I added a new migration in migrations/3_migrate_flatboom.js
that looks like:
var FlatBoomItem = artifacts.require("FlatBoomItem");
module.exports = function(deployer) {
// deployment steps
deployer.deploy(FlatBoomItem);
};
Then perform your migration, it might look something like:
truffle migrate --network=matic
Then, take the receipt and look up the contract, and hit up the "code" section, and hit the "verify and publish" button.
Select facets that match your environment (for me, that meant changing to 0.8.1 compiler, setting optimize to false), and paste in the flattened code into the code block.
There's more info about verifying on blockscout from their docs.
And if you go to "code" in this link here @ https://explorer-mumbai.maticvigil.com/address/0xe0d3f309B3d3bF0ad1dfF00F8a29E5278fD08e0A/contracts
You can see that it's got the source code in plain! ...As opposed to just the bytecode for the EVM.