eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.65k stars 553 forks source link

Contract verification fails. Using custom network for Polygon Mumbai #1605

Closed AgentCosmic closed 1 year ago

AgentCosmic commented 2 years ago

Environment information

What was wrong?

# first I add a new network
brownie networks add Polygon polygon-mumbai host="https://matic-mumbai.chainstacklabs.com" chainid=80001 explorer="https://mumbai.polygonscan.com/"
# then I run my deploy script
brownie run .\scripts\deploy.py --network polygon-mumbai

I get this error:

  File "<console>", line 1, in <module>
  File "C:\Users\dalto\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\contract.py", line 408, in publish_source
    data = response.json()
  File "C:\Users\dalto\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
JSONDecodeError: Expecting value: line 2 column 1 (char 1)

I get the same when running this is brownie console:

>>> es = MyContract.at('0x16D8967d5cB81039EC1EAd440F9305abccFC2fD9')
>>> MyContract.publish_source(es)

This is my deploy script:

def deploy_edusports():
    owner = get_account()
    net = config["networks"][network.show_active()]
    verify = net["verify"]
    return EduSports.deploy(
        {"from": owner},
        publish_source=verify,
    )
MobinHajizadeh commented 1 year ago

Use this brownie networks add Polygon polygon-mumbai host="https://matic-mumbai.chainstacklabs.com" chainid=80001 explorer="https://api-testnet.polygonscan.com/api".

AgentCosmic commented 1 year ago

That works perfectly. The explorer URL was set wrongly. Thank you!