Closed Netherdrake closed 3 years ago
Hi,
Likely the issue you're running into is related to the compiler version or an optimization setting, but it's hard to say for sure. I think the best solution to this is to have Brownie submitting the source code to etherscan via their API.
Etherscan's API accepts either flattened single-file contracts, or standard JSON compiler input. I'm not sure which method I prefer.. as an end user I find the flattened files easier to read, but for composability with other tooling the JSON input is a much cleaner approach. Also generating the JSON input is a part of Brownie's compilation process and so much more straightforward to submit as opposed to having to add logic for flattening.
Some work toward submitting via the API has been done in #651 but it isn't finished yet. It's been on my TODO list for a minute now, but unfortunately never made it to the top. If you have the bandwidth to work on it I'll happily accept a PR :pray: otherwise, best I can offer is that it definitely will happen, but I can't can't say for sure when it will happen.
I tried to quickly modify https://github.com/eth-brownie/brownie/blob/master/brownie/project/compiler/__init__.py to dump standard json input, but etherscan did not accept it.
I will experiment a bit with compiler version and try disabling optimization.
@iamdefinitelyahuman I believe found the appropriate json, but how can I find the appropriately deployed hex constructor ABI to submit to etherscan?
Implemented in #914
Environment information
brownie
Version: ==1.11.5ganache-cli
Version: Ganache CLI v6.10.2 (ganache-core: 2.11.3)solc
Version: Version: 0.6.12+commit.27d51765.Linux.g++What was wrong?
For about half the contacts compiled and deployed via brownie I'm struggling to verify the bytecode on Etherscan.
After deploying a contract with
Contract.deploy(...)
I would use truffle-flattener to generate a single solidity file, and https://abi.hashex.org/ to re-create abi-encoded constructor arguments.I made sure to always check the right compiler version and optimization params.
Here is my brownie config:
When I compile the same contract trough Remix (https://remix.ethereum.org/) it verifies without issues.
Compiled with Brownie: https://etherscan.io/address/0xFD01f7a212eAa4aCAdB986fCb74951D510594c8E#code
Compiled with Remix: https://etherscan.io/address/0x214f2421950de2ee4ff6a394ed677cf296efec0f#code
I really like Brownie and would like to use it to deploy contracts (instead of having to do them by hand via Remix). Any ideas for how to debug this?