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

Feature request: Export code for etherscan verification #564

Closed
xpepermint opened this issue Sep 8, 2017 · 31 comments
Closed

Feature request: Export code for etherscan verification #564

xpepermint opened this issue Sep 8, 2017 · 31 comments

Comments

@xpepermint
Copy link

It seems that there is (still) no straight way to verify your solidity contracts on etherscan.io. Truffle makes it easy to build and deploy real solidity projects. Splitting code into multiple files is a good practice but using imports makes it difficult to verify your contracts on etherscan because you have to provide all your contract's source code as a single file. I use npm libraries to build solidity contracts so you can imagine that it's extreamly difficult to collect all source code.

Truffle could procide a new command verify or export which would build additional files needed for verification proces on etherscan.io.

@xpepermint
Copy link
Author

I found a nice npm package called sol-merger that does this pretty well. We could join forces with author.

@tcoulter
Copy link
Contributor

This sounds like a great idea! I'll add it to our internal tracking. Thanks!

@tcoulter
Copy link
Contributor

Whoops. Closing the issue wasn't what I intended. Reopened.

@Qqwy
Copy link

Qqwy commented Sep 21, 2017

This is a wonderful feature that is very useful.

I've tried multiple times in the past to verify contracts I wrote with Truffle, and it was an absolute hassle; The only times I was able to do so, was when I side-stepped Truffle's deployment pipeline, and manually flattened the source, followed by manually uploading it using Mist or Parity.

I see this as a must-have for any serious smart-contract project. 🙂

@tomasienrbc
Copy link

I would love this feature - I'm actually trying to include a flattener into my scripts now so that I always deploy flattened files so I always can verify the solidity. That will let me develop with separate files but not have to worry about tracking down what Solidity was compiled.

The really frustrating part of this process is that change comments, spacing, or anything about your Solidity results in different binary. You need exactly what was deployed - there's really no way around it.

@moodysalem
Copy link

moodysalem commented Dec 16, 2017

Better yet, it would be nice if truffle verify [--network net] actually made the calls to the etherscan API for the deployed contracts/network to verify the code. I found truffle-flattener to be the best tool for flattening source files, because it is aware of imports coming from npm modules.

@tomasienrbc
Copy link

I agree @moodysalem - Truffle Flattener still has issues but the team is working on making it easier and easier to use every day. It's what I use but it's still not ideal.

@moodysalem
Copy link

@mtbitcoin is it possible for you to expose an API for verifying your contracts? A package that combines truffle-flattener and a call to the etherscan API would be trivial to write

@glaksmono
Copy link

Would love to see this soon!

@stefek99
Copy link

I'm using: https://www.npmjs.com/package/truffle-flattener

Also helpful when exporting to Remix for debugging purposes.

@xpepermint
Copy link
Author

This issue can be closed since truffle-flattener does the trick.

@tomasienrbc
Copy link

@xpepermint @stefek99 I can try this again, but truffle-flattener did not do the trick at the time of posting this issue. Truffle flattener got close but not close enough to map perfectly to Etherscan, not to mention it was impossible to integrate into an automated workflow to run automatically as changes were made.

@michaeljohnbennett
Copy link
Contributor

sol-merger works a treat. I used yesterday and will merge all your deps into one file and it works for deploying to etherscan code. Would be lovely to integrate this into build flow by way of a switch or something.

https://github.com/RyuuGan/sol-merger

@stefek99
Copy link

There is also https://github.com/BlockCatIO/solidity-flattener

Rumors are truffle-flattener is better:
image

@mtbitcoin
Copy link

Would be good to put a list of flatenners that work. I know the blockcat one does.

We can then put together a formal list which would be helpful

@stefek99
Copy link

stefek99 commented Jun 1, 2018

No need a list, just one that works is fine.

@fundrequestbot
Copy link


This issue has been funded using FundRequest. A developer can claim the reward by submitting a pull request referencing this issue. (How to Close Issues via Pull Requests?) e.g. fixes #564

  • For more help on how to claim on issue, please visit our help section.
  • Looking for more? Feel free to browse through all funded requests.

@alpa-coder
Copy link

I just funded this from FundRequest, we verify our contracts everytime we do a deploy. If the process could be simpler/faster it would be a time saver 👍

@burdakovd
Copy link

Despite original issue was about building additional files needed for verification proces on etherscan.io, I think Truffle could go a step further, and instead actuall call etherscan API for verfication. Ideally it would do so for every deployed contract (i.e. in deployer), subject to config option (as I guess some people may prefer not to share source code).

It is at the position to do so, it just deployed a contract, it knows the source code, it knows compiler version, so making human do the work is suboptimal.

@mswezey23
Copy link

@burdakovd Completely agree with you as I've had the some thoughts for over a year now.

Any update on getting a true 1 for 1 Truffle Deployed Smart Contract source code file to verify on etherscan?

@mtbitcoin
Copy link

For reference the API endpoint for the source code verification is available at https://etherscan.io/apis#contracts

@gnidan
Copy link
Contributor

gnidan commented Dec 11, 2018

This is a great candidate for a truffle run plugin, which is part of the Truffle v5 release. See the release notes section about this feature, and stay tuned for more updates to come.

@mswezey23
Copy link

Good callout @mtbitcoin, I found that link earlier today when doing some research since it's been awhile since I looked for a solution last time. Couple that with truffle run as @gnidan suggested would be awesome to see.

I'm going to start work on implementing this within Validity Labs toolchain (to be opensource in the future)

@mtbitcoin
Copy link

We’ve been running that api endpoint for quite a while. It is stable and should have 100% compatibility with the manual source verification on Etherscan (minus the error messages and some input checking). It does however require an api-key which can be generated for free on Etherscan.io

Ping if you have questions

@gnidan
Copy link
Contributor

gnidan commented Jan 9, 2019

Hi all. I'm closing this issue as out-of-scope, since, as mentioned, truffle run should help solve this problem, in addition to the other tools mentioned above. Looking forward to seeing best practices emerge here. Thank you all!

@gnidan gnidan closed this as completed Jan 9, 2019
@JohannesMayerConda
Copy link

@mtbitcoin I tried pretty much every flattener and can't get verification to work. What is the currently recommended way/tool? I'm using solidity 0.5.

@mtbitcoin
Copy link

@JohannesMayerConda if the flattened code compiles in Remix it should also work with ours

@JohannesMayerConda
Copy link

@mtbitcoin truffle-flattener works for me and compiles in remix but it doesn't verify. Their Readme also states

If you deploy your contracts with truffle's migrations the output of truffle-flattener may not match while verifying it in Etherscan

I opened an issue for Flattery https://github.com/akombalabs/SolidityFlattery/issues/2 where I'm stuck

And BlockCatIO/solidity-flattener has open issues like this BlockCatIO/solidity-flattener#26 and does strange things like putting a very old pragma version in the file

Is the solution to get rid of truffle migrations? What is good/best practice? Still the BlockCatIO solidity-flattener that has latest commit Dec 13, 2017?

@rkalis
Copy link
Contributor

rkalis commented Mar 21, 2019

I started work on a truffle plugin to automatically verify source code for deployed truffle contracts. The syntax is currently like this:

truffle run verify SimpleStorage --network rinkeby

Which automatically calls the Etherscan API and returns Pass - Verified or Fail - Unable to verify.

The functionality is still very limited and it doesn't support code flattening yet, so any kinds of contributions to the plugin are welcome!

https://github.com/rkalis/truffle-plugin-verify

@mswezey23
Copy link

I've been working on my own flavor that uses truffle-flattener to flatten the files.
The offset feature, is that you'll need to deploy the contract(s) as how they are flattened. (Remix)
So using truffle to deploy said contracts is a no go unless we can secure 100% deterministic flattening across tools.

With that, I'll write up a small deployer tool that can used along with the flattener and verify-er.
Won't be a truffle plugin, but a separate NPM package that anyone can use along side of the development toolset.

Buidler also has an empty (from last week) repo that's titled to give the impression they are working on ethercan contract verification automation as well.

@rkalis
Copy link
Contributor

rkalis commented May 31, 2019

Hey guys, quick update. Thanks to @vinceau's great work from a few weeks back, truffle-plugin-verify now supports automatic code flattening and verification, and is currently being used in production by @renproject.

Run truffle run verify ContractName [--network networkName] to verify any deployed contract with the Etherscan API. I wrote a short article on my website to get you started, or you can check out the README on the repo.

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