smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.8k stars 2.9k forks source link

Lesson 6 (Brownie FundMe) - Able to deploy to mainnet fork without insufficient funds error #290

Closed luisgc93 closed 2 years ago

luisgc93 commented 3 years ago

For some reason at minute 5:57:26 I don’t get an insufficient funds error when deploying FundMe.sol to mainnet-fork.

Instead the transaction is successful and the contract is deployed. Similarly, I don't get an index error when running accounts[0] in minute 5:59:00.

This is the full console output:

➜  brownie_fund_me brownie run scripts/deploy.py --network mainnet-fork
Brownie v1.17.0 - Python development framework for Ethereum

BrownieFundMeProject is the active project.

Launching 'ganache-cli --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/bd9a329c67044086b423de53c96e5584 --gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'...

Running 'scripts/deploy.py::main'...
Account address is: 0x66aB6D9362d4F35596279692F0251Db635165871
The active network is mainnet-fork.
Transaction sent: 0xa8ae8aac193c57a6709bd9fffa43247648ba15ea3a70fb5d11eb9ad25ec7ab44
  Gas price: 0.0 gwei   Gas limit: 12000000   Nonce: 2
  FundMe.constructor confirmed   Block: 13524986   Gas used: 405169 (3.38%)
  FundMe deployed at: 0xE7eD6747FaC5360f88a2EFC03E00d25789F69291

Contract deployed to 0xE7eD6747FaC5360f88a2EFC03E00d25789F69291
Terminating local RPC client...

And this is my brownie-config.yaml file:

dependencies:
  # - <organization/repo>@<version>
  - smartcontractkit/chainlink-brownie-contracts@1.1.1
compiler:
  solc:
    remappings:
      - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1'
dotenv: .env
networks:
  default: development
  rinkeby:
    eth_usd_price_feed: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'
    verify: True
  mainnet-fork:
    eth_usd_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
    verify: False
  development:
    verify: False
  ganache-local:
    verify: False
wallets:
  from_key: ${PRIVATE_KEY}

Additionally, these are my listed networks on brownie:

➜  brownie_fund_me brownie networks list
Brownie v1.17.0 - Python development framework for Ethereum

The following networks are declared:

Ethereum
  ├─Mainnet (Infura): mainnet
  ├─Ropsten (Infura): ropsten
  ├─Rinkeby (Infura): rinkeby
  ├─Goerli (Infura): goerli
  ├─Kovan (Infura): kovan
  └─ganache-local: ganache-local

Ethereum Classic
  ├─Mainnet: etc
  └─Kotti: kotti

Arbitrum
  └─Mainnet: arbitrum-main

Binance Smart Chain
  ├─Testnet: bsc-test
  └─Mainnet: bsc-main

Fantom Opera
  ├─Testnet: ftm-test
  └─Mainnet: ftm-main

Harmony
  └─Mainnet (Shard 0): harmony-main

Polygon
  ├─Mainnet (Infura): polygon-main
  └─Mumbai Testnet (Infura): polygon-test

XDai
  ├─Mainnet: xdai-main
  └─Testnet: xdai-test

Development
  ├─Ganache-CLI: development
  ├─Geth Dev: geth-dev
  ├─Hardhat: hardhat
  ├─Hardhat (Mainnet Fork): hardhat-fork
  ├─Ganache-CLI (Mainnet Fork): mainnet-fork
  ├─Ganache-CLI (BSC-Mainnet Fork): bsc-main-fork
  ├─Ganache-CLI (FTM-Mainnet Fork): ftm-main-fork
  ├─Ganache-CLI (Polygon-Mainnet Fork): polygon-main-fork
  └─Ganache-CLI (XDai-Mainnet Fork): xdai-main-fork

One thing I've noticed is that if I run:

brownie console --network mainnet-fork

And then I try this, I get an actual account object:

accounts[0]
<Account '0x66aB6D9362d4F35596279692F0251Db635165871'>

I was wondering whether brownie is now perhaps able to do these tutorial steps by itself when first deploying to a mainnet fork (create an account with funds) but it doesn't look like it judging from their releases page: https://github.com/eth-brownie/brownie/releases

Another theory is whether this is somehow handled by Infura, which I'm not still very familiar with.

luisgc93 commented 3 years ago

UPDATE - I've noticed when deploying with brownie run scripts/deploy.py --network mainnet-fork, my Infura project requests go up

image

It looks like I'm deploying to an infura mainnet fork instead of the mainnet fork shown in the tutorial video 🤔

cromewar commented 3 years ago

Make sure your project is taking the configuration, may be a typo on file name in brownie-config.yaml? also don't forget to add the network to your helpful scripts, or get_account wont return what you expect.

luisgc93 commented 2 years ago

I attribute this to a faulty config on my side. Closing this issue.

cromewar commented 2 years ago

I glad you solved your problem

DarrenWayn commented 2 years ago

hey @luisgc93 I have the exact brownie-config.yaml file as you. which one did you changed?

kikaragyozov commented 2 years ago

@cromewar Could you re-investigate this? The files that were posted are correct in regards to the video. It's something else entirely. Let's not fool people who try to learn the real cause to this.

I'm having the same issue, and a few others in https://github.com/smartcontractkit/full-blockchain-solidity-course-py/issues/683 https://github.com/smartcontractkit/full-blockchain-solidity-course-py/issues/729

cromewar commented 2 years ago

@SpiritBob I'm on it, could you please share some info to help the research

please run:

brownie networks list true

and

brownie --version

Share here the results.

DarrenWayn commented 2 years ago

I havent figure this out yet, i only pass it. Still confuse untill today

On Thu, 10 Feb 2022 at 20.51 Vasiliy Gualoto @.***> wrote:

@SpiritBob https://github.com/SpiritBob I'm on it, could you please share some info to help the research

please run:

brownie networks list true

and

brownie --version

— Reply to this email directly, view it on GitHub https://github.com/smartcontractkit/full-blockchain-solidity-course-py/issues/290#issuecomment-1034945881, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKJ6ACXWWVJPHSHJE3Z5L3U2O7HFANCNFSM5HCJJBWQ . You are receiving this because you commented.Message ID: <smartcontractkit/full-blockchain-solidity-course-py/issues/290/1034945881 @github.com>

cromewar commented 2 years ago

I havent figure this out yet, i only pass it. Still confuse untill today On Thu, 10 Feb 2022 at 20.51 Vasiliy Gualoto @.***> wrote: @SpiritBob https://github.com/SpiritBob I'm on it, could you please share some info to help the research please run: brownie networks list true and brownie --version — Reply to this email directly, view it on GitHub <#290 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKJ6ACXWWVJPHSHJE3Z5L3U2O7HFANCNFSM5HCJJBWQ . You are receiving this because you commented.Message ID: <smartcontractkit/full-blockchain-solidity-course-py/issues/290/1034945881 @github.com>

Could you please run the commands above?

kikaragyozov commented 2 years ago

@cromewar Sorry for the late reply.

INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum

The following networks are declared:

Ethereum
  ├─Mainnet (Infura)
  │ ├─id: mainnet
  │ ├─chainid: 1
  │ ├─explorer: https://api.etherscan.io/api
  │ ├─host: https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID
  │ ├─multicall2: 0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696
  │ └─provider: infura
  ├─Ropsten (Infura)
  │ ├─id: ropsten
  │ ├─chainid: 3
  │ ├─explorer: https://api-ropsten.etherscan.io/api
  │ ├─host: https://ropsten.infura.io/v3/$WEB3_INFURA_PROJECT_ID
  │ ├─multicall2: 0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696
  │ └─provider: infura
  ├─Rinkeby (Infura)
  │ ├─id: rinkeby
  │ ├─chainid: 4
  │ ├─explorer: https://api-rinkeby.etherscan.io/api
  │ ├─host: https://rinkeby.infura.io/v3/$WEB3_INFURA_PROJECT_ID
  │ ├─multicall2: 0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696
  │ └─provider: infura
  ├─Goerli (Infura)
  │ ├─id: goerli
  │ ├─chainid: 5
  │ ├─explorer: https://api-goerli.etherscan.io/api
  │ ├─host: https://goerli.infura.io/v3/$WEB3_INFURA_PROJECT_ID
  │ ├─multicall2: 0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696
  │ └─provider: infura
  ├─Kovan (Infura)
  │ ├─id: kovan
  │ ├─chainid: 42
  │ ├─explorer: https://api-kovan.etherscan.io/api
  │ ├─host: https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID
  │ ├─multicall2: 0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696
  │ └─provider: infura
  └─ganache-local
    ├─id: ganache-local
    ├─chainid: 1337
    └─host: http://127.0.0.1:8545

Ethereum Classic
  ├─Mainnet
  │ ├─id: etc
  │ ├─chainid: 61
  │ ├─explorer: https://blockscout.com/etc/mainnet/api
  │ └─host: https://www.ethercluster.com/etc
  └─Kotti
    ├─id: kotti
    ├─chainid: 6
    ├─explorer: https://blockscout.com/etc/kotti/api
    └─host: https://www.ethercluster.com/kotti

Arbitrum
  └─Mainnet
    ├─id: arbitrum-main
    ├─chainid: 42161
    ├─explorer: https://api.arbiscan.io/api
    ├─host: https://arb1.arbitrum.io/rpc
    └─multicall2: 0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858

Avalanche
  ├─Mainnet
  │ ├─id: avax-main
  │ ├─chainid: 43114
  │ ├─explorer: https://api.snowtrace.io/api
  │ └─host: https://api.avax.network/ext/bc/C/rpc
  └─Testnet
    ├─id: avax-test
    ├─chainid: 43113
    └─host: https://api.avax-test.network/ext/bc/C/rpc

Binance Smart Chain
  ├─Testnet
  │ ├─id: bsc-test
  │ ├─chainid: 97
  │ ├─explorer: https://api-testnet.bscscan.com/api
  │ └─host: https://data-seed-prebsc-1-s1.binance.org:8545
  └─Mainnet
    ├─id: bsc-main
    ├─chainid: 56
    ├─explorer: https://api.bscscan.com/api
    └─host: https://bsc-dataseed.binance.org

Fantom Opera
  ├─Testnet
  │ ├─id: ftm-test
  │ ├─chainid: 4002
  │ ├─explorer: https://explorer.testnet.fantom.network
  │ └─host: https://rpc.testnet.fantom.network
  └─Mainnet
    ├─id: ftm-main
    ├─chainid: 250
    ├─explorer: https://api.ftmscan.com/api
    └─host: https://rpc.ftm.tools

Harmony
  └─Mainnet (Shard 0)
    ├─id: harmony-main
    ├─chainid: 1666600000
    ├─host: https://api.harmony.one
    └─multicall2: 0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb

Optimistic Ethereum
  ├─Mainnet
  │ ├─id: optimism-main
  │ ├─chainid: 10
  │ ├─explorer: https://api-optimistic.etherscan.io/api
  │ ├─host: https://mainnet.optimism.io
  │ └─multicall2: 0x2DC0E2aa608532Da689e89e237dF582B783E552C
  └─Kovan
    ├─id: optimism-test
    ├─chainid: 69
    ├─explorer: https://api-kovan-optimistic.etherscan.io/api
    ├─host: https://kovan.optimism.io
    └─multicall2: 0x2DC0E2aa608532Da689e89e237dF582B783E552C

Polygon
  ├─Mainnet (Infura)
  │ ├─id: polygon-main
  │ ├─chainid: 137
  │ ├─explorer: https://api.polygonscan.com/api
  │ ├─host: https://polygon-mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID
  │ └─multicall2: 0xc8E51042792d7405184DfCa245F2d27B94D013b6
  └─Mumbai Testnet (Infura)
    ├─id: polygon-test
    ├─chainid: 80001
    ├─explorer: https://api-testnet.polygonscan.com/api
    ├─host: https://polygon-mumbai.infura.io/v3/$WEB3_INFURA_PROJECT_ID
    └─multicall2: 0x6842E0412AC1c00464dc48961330156a07268d14

XDai
  ├─Mainnet
  │ ├─id: xdai-main
  │ ├─chainid: 100
  │ ├─explorer: https://blockscout.com/xdai/mainnet/api
  │ └─host: https://xdai.poanetwork.dev
  └─Testnet
    ├─id: xdai-test
    ├─chainid: 77
    ├─explorer: https://blockscout.com/poa/sokol/api
    └─host: https://sokol.poa.network

Development
  ├─Ganache-CLI
  │ ├─id: development
  │ ├─cmd: ganache-cli
  │ └─host: http://127.0.0.1
  │   ├─accounts: 10
  │   ├─evm_version: istanbul
  │   ├─gas_limit: 12000000
  │   ├─mnemonic: brownie
  │   └─port: 8545
  ├─Geth Dev
  │ ├─id: geth-dev
  │ ├─cmd: ethnode
  │ └─host: http://127.0.0.1
  │   └─port: 8545
  ├─Hardhat
  │ ├─id: hardhat
  │ ├─cmd: npx hardhat node
  │ └─host: http://localhost
  │   └─port: 8545
  ├─Hardhat (Mainnet Fork)
  │ ├─id: hardhat-fork
  │ ├─cmd: npx hardhat node
  │ ├─host: http://localhost
  │ └─timeout: 120
  │   ├─fork: mainnet
  │   └─port: 8545
  ├─Ganache-CLI (Mainnet Fork)
  │ ├─id: mainnet-fork
  │ ├─cmd: ganache-cli
  │ ├─host: http://127.0.0.1
  │ └─timeout: 120
  │   ├─accounts: 10
  │   ├─evm_version: istanbul
  │   ├─fork: mainnet
  │   ├─gas_limit: 12000000
  │   ├─mnemonic: brownie
  │   └─port: 8545
  ├─Ganache-CLI (BSC-Mainnet Fork)
  │ ├─id: bsc-main-fork
  │ ├─cmd: ganache-cli
  │ ├─host: http://127.0.0.1
  │ └─timeout: 120
  │   ├─accounts: 10
  │   ├─evm_version: istanbul
  │   ├─fork: bsc-main
  │   ├─gas_limit: 12000000
  │   ├─mnemonic: brownie
  │   └─port: 8545
  ├─Ganache-CLI (FTM-Mainnet Fork)
  │ ├─id: ftm-main-fork
  │ ├─cmd: ganache-cli
  │ ├─host: http://127.0.0.1
  │ └─timeout: 120
  │   ├─accounts: 10
  │   ├─evm_version: istanbul
  │   ├─fork: ftm-main
  │   ├─gas_limit: 12000000
  │   ├─mnemonic: brownie
  │   └─port: 8545
  ├─Ganache-CLI (Polygon-Mainnet Fork)
  │ ├─id: polygon-main-fork
  │ ├─cmd: ganache-cli
  │ ├─host: http://127.0.0.1
  │ └─timeout: 120
  │   ├─accounts: 10
  │   ├─evm_version: istanbul
  │   ├─fork: polygon-main
  │   ├─gas_limit: 20000000
  │   ├─mnemonic: brownie
  │   └─port: 8545
  ├─Ganache-CLI (XDai-Mainnet Fork)
  │ ├─id: xdai-main-fork
  │ ├─cmd: ganache-cli
  │ ├─host: http://127.0.0.1
  │ └─timeout: 120
  │   ├─accounts: 10
  │   ├─evm_version: istanbul
  │   ├─fork: xdai-main
  │   ├─gas_limit: 20000000
  │   ├─mnemonic: brownie
  │   └─port: 8545
  └─Ganache-CLI (Avax-Mainnet Fork)
    ├─id: avax-main-fork
    ├─cmd: ganache-cli
    ├─host: http://127.0.0.1
    └─timeout: 120
      ├─accounts: 10
      ├─evm_version: istanbul
      ├─fork: avax-main
      ├─gas_limit: 20000000
      ├─mnemonic: brownie
      └─port: 8545
cromewar commented 2 years ago

@PatrickAlphaC I've been doing research on this but with no luck, some people are reporting not getting the same error as you do on time stamp 5:57:26 as the test passes without problems. At first I tough this was related to the brownie configuration on their side, but I've found nothing relevant so far. Any clue on this?

PatrickAlphaC commented 2 years ago

Do you have money in mainnet of the wallet you're using?

kikaragyozov commented 2 years ago

@PatrickAlphaC I didn't have any money, and yet it passed. I believe brownie had some changes. We just need to understand what they are and explain them here, as to the reasoning why people don't get an error when previously they "should" have.

PatrickAlphaC commented 2 years ago

Hm.... it's likely using a fake account along with the mainnet fork instead of looking into your actual account.

DarrenWayn commented 2 years ago

@PatrickAlphaC so what does it mean Patric? are you saying brownie default looking for a fake account instead of my main acc? then how to make a brownie use the actual acc?

PatrickAlphaC commented 2 years ago

Is that what you want?

If you want that, you could do a my_account = accounts.add(<YOUR_KEY>) and make transactions from there.