0

While working and deploying the FundMe.sol Patric Collins tutorial on FreeCodeCamp. I stumbled upon the following error generated while trying to publish the source when using FundMe.deploy({"from":account}, publish_source=True). The error generated in Brownie is as follow's: raise ValueError(f"API request failed with: {data['result']}") ValueError: API request failed with: []. If anyone knows a solution to this issue it would be a great help.

What I have already tried:

  • Running a test in order to debug.
  • Trying to remove SafeMath (After reading get_verification_info inside --pdb led me to remove it.)
  • Trying to verify the Rinkeby Etherscan API url via curl
  • Rechecking my .env
  • Trying to ask on Discord/Other Communities.
  • Checking Github Pages/Google/StackOverflow/Eth-Stackoverflow for a solution.

Here is the source-code for deploy.py:

def deploy_fund_me():
    # Getting the account.
    account = get_account()
    # Deploying Contract with publish_source=True
    fund_me = FundMe.deploy({"from":account}, publish_source=True)
    print(f"[Contract] Contract Deployed to {fund_me.address}")

2 Answers 2

0

Alright! A Bit more Stumbling and I found a working solution. Turn's out I also need to add the following to brownie-config.yaml. Brownie does not automatically use Infura and we need to manually add it to the networks. After adding the below code and running deploy.py using, brownie run ./scripts/deploy.py --network rinkeby. The publishing is successful.

To fix the above error, Simply add the below code to your already existing (or create one) brownie-config.yaml, If you are working on other networks. Modify the below code accordingly. \

live:
  - name: Ethereum
    networks:
      - name: Rinkeby (Infura)
        chainid: 4
        id: rinkeby
        host: https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID
        explorer: https://api-rinkeby.etherscan.io/api

Reference to the above solution can be found @ "Common Pitfalls" by Matnad

0

I use a .env file in my project folder with

export ETHERSCAN_TOKEN=xxxx
export WEB3_INFURA_PROJECT_ID=xxxx

then in the brownie-config.yaml all you have to do is add dotenv: .env and publish_source=True will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.