New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Export code for etherscan verification #564

Open
xpepermint opened this Issue Sep 8, 2017 · 24 comments

Comments

Projects
None yet
@xpepermint

xpepermint commented Sep 8, 2017

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

This comment has been minimized.

xpepermint commented Sep 9, 2017

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

@tcoulter

This comment has been minimized.

Contributor

tcoulter commented Sep 15, 2017

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

@tcoulter tcoulter closed this Sep 15, 2017

@tcoulter

This comment has been minimized.

Contributor

tcoulter commented Sep 15, 2017

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

@Qqwy

This comment has been minimized.

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

This comment has been minimized.

tomasienrbc commented Nov 25, 2017

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

This comment has been minimized.

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

This comment has been minimized.

tomasienrbc commented Dec 16, 2017

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

This comment has been minimized.

moodysalem commented Dec 16, 2017

@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

This comment has been minimized.

glaksmono commented Feb 19, 2018

Would love to see this soon!

@stefek99

This comment has been minimized.

stefek99 commented May 31, 2018

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

Also helpful when exporting to Remix for debugging purposes.

@xpepermint

This comment has been minimized.

xpepermint commented May 31, 2018

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

@tomasienrbc

This comment has been minimized.

tomasienrbc commented May 31, 2018

@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

This comment has been minimized.

michaeljohnbennett commented May 31, 2018

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

This comment has been minimized.

stefek99 commented May 31, 2018

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

Rumors are truffle-flattener is better:
image

@mtbitcoin

This comment has been minimized.

mtbitcoin commented May 31, 2018

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

This comment has been minimized.

stefek99 commented Jun 1, 2018

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

@fundrequestbot

This comment has been minimized.

fundrequestbot commented Jun 1, 2018


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.
@davyvanroy

This comment has been minimized.

davyvanroy commented Jun 1, 2018

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

This comment has been minimized.

burdakovd commented Nov 4, 2018

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

This comment has been minimized.

mswezey23 commented Dec 11, 2018

@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

This comment has been minimized.

mtbitcoin commented Dec 11, 2018

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

@gnidan

This comment has been minimized.

Member

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

This comment has been minimized.

mswezey23 commented Dec 11, 2018

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

This comment has been minimized.

mtbitcoin commented Dec 12, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment