brownie icon indicating copy to clipboard operation
brownie copied to clipboard

Verify and publish the source of an earlier deployed contract that has constructor arguments

Open LE0xUL opened this issue 2 years ago • 2 comments

Overview

I have a verified deployed contract factory, but I can't use the contract.publish_source function in contracts created through the factory, because that function doesn't support "constructor arguments", and fail the result of Verification

Specification

I've created the contract object of the deployed contract using the .at method

>>> MyContract.at("0xAD3...519")
>>> MyContract.publish_source(MyContract[0])
Verification submitted successfully. Waiting for result...
Verification pending...
Verification complete. Result: Fail - Unable to verify
False

I think that verification fails because I can't put the constructor arguments used in the factory.

The ETHERSCAN_TOKEN is corrected set because the deployment and verification of the factory are successful.

LE0xUL avatar Jun 22 '22 00:06 LE0xUL

This would be usefull tbh, verifying contracts deployed by factories is a pain. My error code is different tho:

>>> MyContract.publish_source(MyContract[-1])
Waiting for https://api.etherscan.io/api to process contract...
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 417, in publish_source
    raise ValueError(f"API request failed with: {data['result']}")
ValueError: API request failed with: []

Also, I managed to verify mine with https://github.com/eth-brownie/brownie/issues/1417#issuecomment-1076246944:

import json
from brownie import MyContract

def main():
    with open('MyContract.json', 'w') as f:
        f.write(
            json.dumps(
                MyContract.get_verification_info()['standard_json_input']
            )
        )

and using the ABI-encoded constructor arguments directly from the deployed contract bytecode, but you can also use web3js for that.

DennisDv24 avatar Aug 06 '22 11:08 DennisDv24

Manually generated standard_json_input also fails when you have local libraries in your project. Refer to #1603

Jeevan-J avatar Aug 31 '22 18:08 Jeevan-J