PatrickAlphaC / brownie_fund_me

26 stars 64 forks source link

IndexError: list index out of range #44

Open vedmukherjee15 opened 2 years ago

vedmukherjee15 commented 2 years ago

withdraw Whenever I run the above code I get an index error. Please help me out @PatrickAlphaC @cromewar

JayAlwaysCodes commented 2 years ago

I also got the same error, i have been stucked here for over 2days, please if you find the solution, simply post it here too

cromewar commented 2 years ago

Hello @vedmukherjee15 @JayAlwaysCodes This is "normal", the explanation is simple. When you use [-1] you are referring to the last instance of that deployed contract, but it has it's limitations. In order to access to that [-1} it means the contract address should exist on the build/deployments folder, otherwise it wont find it. So, this will work just with networks with persistence, like rinkeby, kovan or a Pseudo persistence ganache instance, if you try to run this on development it wont work, as there is not a folder on build for that network. Development network just works on the runtime execution, it means once the process is finished all the data gets deleted, so that's why you cannot access to the index [-1].

My recommendation is just deploy on a network with persistence and that's it.

Cheers.

JayAlwaysCodes commented 2 years ago

thanks @cromewar... i tried deploying to rinkeby and it reverted, what could have caused it? it really feels discouraging , i will be glad if you can provide solution to this. reverted error

PatrickAlphaC commented 2 years ago

Try this.

  1. Delete your build folder.
  2. Re-deploy (wait for txes to go through and see it on ethersca)
  3. Run again
JayAlwaysCodes commented 2 years ago

Thanks, It worked