brownie
brownie copied to clipboard
Verify and publish the source of an earlier deployed contract that has constructor arguments
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.
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.
Manually generated standard_json_input
also fails when you have local libraries in your project. Refer to #1603