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

Cannot verify source during contract deployment on SnowTrace #1417

Open aaron-cesaro opened 2 years ago

aaron-cesaro commented 2 years ago

Environment information

network not recognized using publish_source with SnowTrace API-KEY

I checked everything related to publish_source but seems that this isn't working properly.

Here's all relevant info about the code

brownie-config.yaml

dotenv: .env
wallets:
  from_key: ${PRIVATE_KEY}
networks:
  default: development
  avax-test:
    publish_source: True

.env [values are intentionally hidden]

export PRIVATE_KEY=0x3...XXXXX....53f
export WEB3_INFURA_PROJECT_ID=d8c556...XXXXX....f2fb
export ETHERSCAN_TOKEN=ADZZ...XXXXX....W739Z
export SNOWTRACE_TOKEN=DYH...XXXXX....W6J87

deploy.py

account = accounts.add(config["wallets"]["from_key"])
deploy_contract = TestContract.deploy(
            {"from": account},
            publish_source=config["networks"][network.show_active()].get(
                "publish_source", False
            ),

run command

brownie run deploy.py --network avax-test

brownie run deploy.py --network avax-test
Brownie v1.17.2 - Python development framework for Ethereum

TestV3Project is the active project.

Running 'scripts/deploy.py::main'...
Transaction sent: 0x3f902d323daa087700f30a0fc64b146a21d8d64f66b8c68062eca842c6cdbea7
  Gas price: 25.0 gwei   Gas limit: 3459062   Nonce: 15
  TestContract.constructor confirmed   Block: 5518373   Gas used: 3144602 (90.91%)
  TestContract deployed at: 0xA9B2EFDf55c8361e537e0Bd21403C58bF4B96d74

  File "brownie/_cli/run.py", line 50, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "./scripts/deploy.py", line 25, in deploy_test_contract
    deploy_contract  = TestContract.deploy(
  File "brownie/network/contract.py", line 528, in __call__
    return tx["from"].deploy(
  File "brownie/network/account.py", line 557, in deploy
    contract.publish_source(deployed_contract, silent=silent)
  File "brownie/network/contract.py", line 317, in publish_source
    raise ValueError("Explorer API not set for this network")
ValueError: Explorer API not set for this network
matthiaszimmermann commented 2 years ago

potential duplicate for #1459

matthiaszimmermann commented 2 years ago

"workaround" that i'm using so far: manually upload/verify source code on snowtrace testnet using Solidity Standard Json-Input

the necessary json file can be created using brownie (eg brownie console as shown below for a 'Registry' contract)

>>> import json
>>> with open('Registry.json','w') as f: f.write(json.dumps(Registry.get_verification_info()['standard_json_input']))