Is this (Verify smart contract inheriting from OpenZeppelin Contracts) possibile with xdai network?
I’m looking for the same right now, I’ve just found Celo’s truffle plugin but hasn’t been updated in a while, haven’t tried it yet.
Please share any progress @Dan_Rusnac
Hi @Dan_Rusnac,
Welcome to the community
The Block Scout instructions suggest flattening. Whilst I prefer multi-file verification, flattening may be the easiest way to go with.
If you flatten, you will need to ensure that the license you use for the flattened file is compatible with any imports. OpenZeppelin Contracts uses MIT license.
@martriay @abcoathup
So I found a way to verify the smart contract (but I had to refactor the folder structure of my project). Those are my steps:
- Before migrating, compiling, etc. the first thing I do is to flatten the contract. To do this I’m using this tool (https://www.npmjs.com/package/truffle-flattener)
truffle-flattener dev/Contract.sol > contracts/Contract.flattened.sol
- Then when I compile (with truffle) I do not compile my original contracts but only the flattened one. To achieve this I had to move all my contracts files from the folder “contracts” inside another folder (I call it “dev” for now). This way inside the contracts folder I have only the flattened file and the migrations, this way I can do
truffle compile
and it automatically selects the flattened contract. (any suggestion on how to improve this part?) - At this point I deploy my compiled contracts with
truffle migrate --reset --network xdai
- Finally I go on my contract’s Blockscout page, and manually verify my contract through the flattened file I used.
This is the only way I managed to verify my contract. The only part I don’t like is the folder scheme refactor.
I also tried with this plugin: https://www.npmjs.com/package/truffle-source-verify
I tried with truffle run blockscout SomeContractName AnotherContractName --network networkName --license UNLICENSED [--debug]
but it always returns me a 504 error.
Edit: I just want to mention that creating flattened files after deploy won’t verify the smart contract on xDai, it will always give you a bytecode error for some reason, this is why I had to move this fase as the first one.
Edit2: I also had to remove all the licenses from the Openzeppelin contracts and only leave the one inside my contract because I was getting a compilation error on too many licenses. (I use MIT license too, so no big problem but for contracts with different license types I suppose it could be a problem)
Hi @Dan_Rusnac,
Thanks for sharing your process. Verification is still a major pain point for the ecosystem.
I assume that Truffle Source Verify only supports Etherscan.
The compiler enforces only one license per file, so developers need to ensure that they use an appropriate license. Using MIT when importing OpenZeppelin Contracts makes things a lot easier.