ℹ️ Important: This repo is no longer maintained; we invite all people learning Solidity to head to Cyfrin Updraft! The 100% free #1 smart contract education platform on earth. Developed with love by Patrick & Cyfrin <3
brownie_fund_me's Introduction
brownie_fund_me's People
Forkers
shonuff1221 olafswan void-rune sn4k3ss spchung blockchain-course offgridauthor devojoyti green-tea gustavodago chanleyou jayakumar9 t-digg samratkar77 pguso nvaish1 singhkaramjeet johnnychen765 enraw tnwill jigar3 alexandrekuzo ccjenkins14 abd101k direwolf707 tmavrin chapola mellamovalen swapnanilsharma swapnamoy45 jeanjulesbigeard dabors liam-hughes seek4samurai c054867 rahul-art kumarsuraj9450 danielcawley mr-ziash kubesqrt bapi-reddy nodemadic farshad127 bartclaessens rishigarg256 uvvirus eemedison oliverthomsen anaslachheb slothkins louisdtt xblue-light my922 relaxeddong cromewar srungarapugopikrishna taner2344 jatin020403 t1murko akshithavvr yimmyeman phoenix-zh mz-zareibrownie_fund_me's Issues
[Duplicate] test_only_owner_can_withdraw() throws AttributeError instead of VirtualMachineError
from scripts.helpers import get_account, LOCAL_BLOCKCHAIN_ENVIRONMENTS
from scripts.deploy import deploy_fund_me
from brownie import network, accounts, exceptions
import pytest
def test_can_fund_and_withdraw():
account = get_account()
fund_me = deploy_fund_me()
entrance_fee = fund_me.getEntranceFee() + 100
tx = fund_me.fund({"from": account, "value": entrance_fee})
tx.wait(1)
assert fund_me.addressToAmountFunded(account.address) == entrance_fee
tx2 = fund_me.withdraw({"from": account})
tx2.wait(1)
assert fund_me.addressToAmountFunded(account.address) == 0
def test_only_owner_can_withdraw():
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip("only for local testing")
# account = get_account()
fund_me = deploy_fund_me()
bad_actor = accounts.add()
fund_me.withdraw({"from": bad_actor})
# with pytest.raises(exceptions.VirtualMachineError):
# fund_me.withdraw({"from": bad_actor})
brownie test -k test_only_owner_can_withdraw
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum
=============================== test session starts ================================
platform win32 -- Python 3.8.8, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: D:\College + Study\Courses\Solidity, Blockchain and Smart Contracts\brownie\fund_me
plugins: eth-brownie-1.17.2, hypothesis-6.27.3, forked-1.3.0, xdist-1.34.0, web3-5.25.0
collected 2 items / 1 deselected / 1 selected
Launching 'ganache-cli.cmd --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
tests\test_fund_me.py F [100%]
===================================== FAILURES =====================================
___________________________ test_only_owner_can_withdraw ___________________________
def test_only_owner_can_withdraw():
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip("only for local testing")
# account = get_account()
fund_me = deploy_fund_me()
bad_actor = accounts.add()
> fund_me.withdraw({"from": bad_actor})
tests\test_fund_me.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1629: in __call__
return self.transact(*args)
C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1502: in transact
return tx["from"].transfer(
C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py:682: in transfer
receipt._raise_if_reverted(exc)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Transaction '0x7dbae07c4cd6854eba8d10cb92440ce5d50c3b53be61e25927dc512ad17613ea'>
exc = None
def _raise_if_reverted(self, exc: Any) -> None:
if self.status or CONFIG.mode == "console":
return
if not web3.supports_traces:
# if traces are not available, do not attempt to determine the revert reason
raise exc or ValueError("Execution reverted")
if self._dev_revert_msg is None:
# no revert message and unable to check dev string - have to get trace
self._expand_trace()
if self.contract_address:
source = ""
elif CONFIG.argv["revert"]:
source = self._traceback_string()
else:
source = self._error_string(1)
contract = state._find_contract(self.receiver)
if contract:
marker = "//" if contract._build["language"] == "Solidity" else "#"
line = self._traceback_string().split("\n")[-1]
if marker + " dev: " in line:
self._dev_revert_msg = line[line.index(marker) + len(marker) : -5].strip()
> raise exc._with_attr(
source=source, revert_msg=self._revert_msg, dev_revert_msg=self._dev_revert_msg
)
E AttributeError: 'NoneType' object has no attribute '_with_attr'
C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\transaction.py:446: AttributeError
------------------------------- Captured stdout call -------------------------------
The acitve network is development
Deploying mocks...
Mocks deployed
Contract deployed to 0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6
mnemonic: 'fortune shrug mass west priority reopen document private enemy spike loop depth'
============================= short test summary info ==============================
FAILED tests/test_fund_me.py::test_only_owner_can_withdraw - AttributeError: 'None...
========================= 1 failed, 1 deselected in 7.16s ==========================
Terminating local RPC client...
ValueError: execution reverted: VM Exception while processing transaction: revert Please Help
Hi please i ran into a problem while deploying Brownie Fund_and_withdraw.py script through ganache-local network already spent 3 days trying to find a quick solution. when i run brownie run scripts/deploy.py --network ganache-local. my script ran successfully but when i try interact with added Fund_and_withdraw.py script i got this error
Running 'scripts/fund_and_withdraw.py::main'...
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/fund_and_withdraw.py", line 22, in main
fund_me()
File "./scripts/fund_and_withdraw.py", line 8, in fund_me
entrance_fee = fund_me.getEntranceFee()
File "brownie/network/multicall.py", line 115, in _proxy_call
result = ContractCall.call(*args, **kwargs) # type: ignore
File "brownie/network/contract.py", line 1902, in call
return self.call(*args, block_identifier=block_identifier, override=override)
File "brownie/network/contract.py", line 1693, in call
raise VirtualMachineError(e) from None
File "brownie/exceptions.py", line 93, in init
raise ValueError(str(exc)) from None
ValueError: execution reverted: VM Exception while processing transaction: revert
I also checked ganache cli Logs here's the output :
eth_call[8:54:53 PM] > {[8:54:53 PM] > "jsonrpc": "2.0",[8:54:53 PM] > "method": "eth_call",[8:54:53 PM] > "params": [[8:54:53 PM] > {[8:54:53 PM] > "to": "0x8309ABC2528f652823Cad736d35B612fcF6aaBc6",[8:54:53 PM] > "data": "0x09bc33a7"[8:54:53 PM] > },[8:54:53 PM] > "latest"[8:54:53 PM] > ],[8:54:53 PM] > "id": 7[8:54:53 PM] > }[8:54:53 PM] < {[8:54:53 PM] < "id": 7,[8:54:53 PM] < "jsonrpc": "2.0",[8:54:53 PM] < "error": {[8:54:53 PM] < "message": "VM Exception while processing transaction: revert",[8:54:53 PM] < "code": -32000,[8:54:53 PM] < "data": {[8:54:53 PM] < "0x6656326ec950a3a1b1cfc3103cc1bfb427e74c8045c75e278525ac33a46868c4": {[8:54:53 PM] < "error": "revert",[8:54:53 PM] < "program_counter": 995,[8:54:53 PM] < "return": "0x"[8:54:53 PM] < },[8:54:53 PM] < "stack": "RuntimeError: VM Exception while processing transaction: revert\n at Function.RuntimeError.fromResults (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/utils/runtimeerror.js:94:13)\n at /Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/blockchain_double.js:568:26",[8:54:53 PM] < "name": "RuntimeError"[8:54:53 PM] < }
[Duplicated] Brownie - Constructor Sequence has incorrect length, expected 1 but got 0
FreeCodeCamp VIDEO at 5:15:45
I am trying to deploy the FundMe contract on Rinkeby by running brownie run scripts/deploy.py --network rinkeby
but I get following error:
Constructor Sequence has incorrect length, expected 1 but got 0
I think the problem is that I do NOT specify the initial value of the constructor when I run my deploy.py script. Is it correct? If yes, how can I fix it?
deploy.py
from brownie import FundMe
from scripts.helpful_script import get_account
def deploy_fund_me():
account = get_account()
fund_me = FundMe.deploy({"from": account})
print(f"Contract deployed to {fund_me.account}")
Solidity contract
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
...OTHER FUNCTIONS...
}
}
Please Help ValueError: execution reverted: VM Exception while processing transaction: revert unable to run Fund_and_withdraw.py script #1560
No response from the main repo issue #1560 I've seen some other people running into this but their fixes did not work for me.
Hi please i ran into a problem while deploying Brownie Fund_and_withdraw.py script through ganache-local network already spent 3 days trying to find a quick solution. when i run brownie run scripts/deploy.py --network ganache-local. my script ran successfully but when i try interact with added Fund_and_withdraw.py script i got this errorRunning 'scripts/fund_and_withdraw.py::main'...
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/fund_and_withdraw.py", line 22, in main
fund_me()
File "./scripts/fund_and_withdraw.py", line 8, in fund_me
entrance_fee = fund_me.getEntranceFee()
File "brownie/network/multicall.py", line 115, in _proxy_call
result = ContractCall.call(*args, **kwargs) # type: ignore
File "brownie/network/contract.py", line 1902, in call
return self.call(*args, block_identifier=block_identifier, override=override)
File "brownie/network/contract.py", line 1693, in call
raise VirtualMachineError(e) from None
File "brownie/exceptions.py", line 93, in init
raise ValueError(str(exc)) from None
ValueError: execution reverted: VM Exception while processing transaction: revert
I also checked ganache cli Logs here's the output :
eth_call[8:54:53 PM] > {[8:54:53 PM] > "jsonrpc": "2.0",[8:54:53 PM] > "method": "eth_call",[8:54:53 PM] > "params": [[8:54:53 PM] > {[8:54:53 PM] > "to": "0x8309ABC2528f652823Cad736d35B612fcF6aaBc6",[8:54:53 PM] > "data": "0x09bc33a7"[8:54:53 PM] > },[8:54:53 PM] > "latest"[8:54:53 PM] > ],[8:54:53 PM] > "id": 7[8:54:53 PM] > }[8:54:53 PM] < {[8:54:53 PM] < "id": 7,[8:54:53 PM] < "jsonrpc": "2.0",[8:54:53 PM] < "error": {[8:54:53 PM] < "message": "VM Exception while processing transaction: revert",[8:54:53 PM] < "code": -32000,[8:54:53 PM] < "data": {[8:54:53 PM] < "0x6656326ec950a3a1b1cfc3103cc1bfb427e74c8045c75e278525ac33a46868c4": {[8:54:53 PM] < "error": "revert",[8:54:53 PM] < "program_counter": 995,[8:54:53 PM] < "return": "0x"[8:54:53 PM] < },[8:54:53 PM] < "stack": "RuntimeError: VM Exception while processing transaction: revert\n at Function.RuntimeError.fromResults (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/utils/runtimeerror.js:94:13)\n at /Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/blockchain_double.js:568:26",[8:54:53 PM] < "name": "RuntimeError"[8:54:53 PM] < }
Please Any idea on how to solve this . Thanks in advance
Unable to fetch the AggregatorV3
ParserError: Source "C:/Users/lenovo/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File not found.
--> contracts/fundme.sol:3:1:
|
3 | import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Have the same code as Patrick, in fundme.sol and brownie-config.yaml
Unable to Compile With MockV3Aggregator after changing chainlink-brownie-contracts version to 0.2.2
Hello everybody! I'm having a little trouble compiling MockV3Aggregator.sol file. I changed the chainlink-brownie-contracts version to 0.2.2, as it is recommended in this issue, but it still does not work.
Any other suggestion, will be grate.
The error is the following:
`Brownie v1.17.2 - Python development framework for Ethereum
New compatible solc version available: 0.6.0
Compiling contracts...
Solc version: 0.6.0
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
/home/username/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:38: TypeError: Interfaces cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-----------------^
/home/username/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:59: TypeError: Interfaces cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-------------------^`
Also, I'm changing the version in the config file, both in the "dependencies" and "remapping" sections. I don't know if maybe I'm changing this in the wrong section?
Thanks in advance!
Brownie - Constructor Sequence has incorrect length, expected 1 but got 0
FreeCodeCamp VIDEO at 5:15:45
I am trying to deploy the FundMe contract on Rinkeby by running brownie run scripts/deploy.py --network rinkeby
but I get following error:
Constructor Sequence has incorrect length, expected 1 but got 0
I think the problem is that I do NOT specify the initial value of the constructor when I run my deploy.py script. Is it correct? If yes, how can I fix it?
deploy.py
from brownie import FundMe
from scripts.helpful_script import get_account
def deploy_fund_me():
account = get_account()
fund_me = FundMe.deploy({"from": account})
print(f"Contract deployed to {fund_me.account}")
Solidity contract
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
...OTHER FUNCTIONS...
}
}
Beginning of fund_and_withdraw.py Section, Unable to come up with the same print(entrance_fee) value as in the video.
I keep coming up with 2500000 when running scripts.fund_and_withdraw.py.
I've seen some other people running into this but their fixes did not work for me.
Please let it be something bleedingly obvious wrong with me code. fingers crossed.
Here is my code:
fund_and_withdraw.py:
from brownie import FundMe
from scripts.helpful_scripts import get_account
def fund():
fund_me = FundMe[-1]
account = get_account()
entrance_fee = fund_me.getEntranceFee()
print(entrance_fee)
def main():
fund()
FundMe.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
// if you're following along with the freecodecamp video
// Please see https://github.com/PatrickAlphaC/fund_me
// to get the starting solidity contract code, it'll be slightly different than this!
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
function fund() public payable {
uint256 minimumUSD = 50 * 10**18;
require(
getConversionRate(msg.value) >= minimumUSD,
"You need to spend more ETH!"
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
return priceFeed.version();
}
function getPrice() public view returns (uint256) {
(, int256 answer, , , ) = priceFeed.latestRoundData();
return uint256(answer * 10000000000);
}
// 1000000000
function getConversionRate(uint256 ethAmount)
public
view
returns (uint256)
{
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
return ethAmountInUsd;
}
function getEntranceFee() public view returns (uint256) {
// minimumUSD
uint256 minimumUSD = 50 * 10**18;
uint256 price = getPrice();
uint256 precision = 1 * 10**18;
return (minimumUSD * precision) / price;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function withdraw() public payable onlyOwner {
msg.sender.transfer(address(this).balance);
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
}
}
deploy.py:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
// if you're following along with the freecodecamp video
// Please see https://github.com/PatrickAlphaC/fund_me
// to get the starting solidity contract code, it'll be slightly different than this!
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
function fund() public payable {
uint256 minimumUSD = 50 * 10**18;
require(
getConversionRate(msg.value) >= minimumUSD,
"You need to spend more ETH!"
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
return priceFeed.version();
}
function getPrice() public view returns (uint256) {
(, int256 answer, , , ) = priceFeed.latestRoundData();
return uint256(answer * 10000000000);
}
// 1000000000
function getConversionRate(uint256 ethAmount)
public
view
returns (uint256)
{
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
return ethAmountInUsd;
}
function getEntranceFee() public view returns (uint256) {
// minimumUSD
uint256 minimumUSD = 50 * 10**18;
uint256 price = getPrice();
uint256 precision = 1 * 10**18;
return (minimumUSD * precision) / price;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function withdraw() public payable onlyOwner {
msg.sender.transfer(address(this).balance);
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
}
}
helpful_scripts:
from brownie import network, config, accounts, MockV3Aggregator
from web3 import Web3
DECIMALS = 8
STARTING_PRICE = 200000000000
LOCAL_BLOCKCHAIN_ENVIRONMENTS = ["development", "ganache-local"]
def get_account():
if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
return accounts[0]
else:
return accounts.add(config["wallets"]["from_key"])
def deploy_mocks():
print(f"The active network is {network.show_active()}")
print("Deploying Mocks")
if len(MockV3Aggregator) <= 0:
MockV3Aggregator.deploy(DECIMALS, STARTING_PRICE, {"from": get_account()})
print("Mocks Deployed!")
Any and all advice is appreciated!
ImportError: cannot import name 'deploy_mocks' from 'scripts.helpful_scripts'
Brownie output says contract deployed, but not able to verify it on etherscan
I made a python program "deploy.py" to deploy a solidity "FundMe.sol" contract. from brownie import FundMe, accounts,
config from scripts.helpful_scripts import get_account
from brownie import FundMe, accounts, config
from scripts.helpful_scripts import get_account
def deploy_fund_me():
account = accounts.add(config["wallets"]["from_key"])
print(account)
fund_me = FundMe.deploy({"from": account})
print("---------Contract Deployed to ", fund_me.address)
def main():
deploy_fund_me()
When I run the deploy.py program, I get an output which says that the contract has been deployed on the given address.
Binoy John@DESKTOP-ATPUI3D MINGW64~/Desktop/Binoy/project/BlockChain/demos/brownie_fund_me
$ brownie run deploy.py --network rinkeby
INFO: Could not find files for the given pattern(s).
Brownie v1.16.4 - Python development framework for Ethereum
BrownieFundMeProject is the active project.
Running 'scripts\deploy.py::main'...
0x9AEa174491c2ecF7920021CE4252270777810ee8
Transaction sent: 0x303eee544cab7eec134e7a56d9f85735dbb972a924466cd2610654b17ecd7ff5
Gas price: 1.679044371 gwei Gas limit: 397721 Nonce: 121
FundMe.constructor confirmed Block: 10054471 Gas used: 361565 (90.91%)
FundMe deployed at: 0xFc4836fe3593e9b434513A48c9CBA04EE019ccC8
---------Contract Deployed to 0xFc4836fe3593e9b434513A48c9CBA04EE019ccC8
However, when I paste the contract address on the Rinkeby Etherscan website, it says "There are no matching entries" and does not show any transfer or verification of deployment of the contract.
Please let me know where have I gone wrong as I am a noob at this. Also let me know if you need any other info to help me out with this problem. Thanks in advance!!
if get_account(): File line, line 988, in times] RecursionError: maximum recursion depth exceeded
Can anyone know how to solve this?
Brownie fails to attached to local RPC client
Problem:I am not able to deploy my smart contract on persistent ganache
Steps to repeat:
- All steps proceeding the 5:37 hour mark of the youtube video
- Launch ganache local chain through GUI
- Run
$ brownie run scripts/deploy.py
in terminal
Receive:
Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
Running 'scripts/deploy.py::main'...
The active network is development
Deploying Mocks....
Transaction sent: 0x59f451022f09b1da1a9f9df54795e7dbdb88ac3618ec773bc17ae2a1b518ed4e
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 0
MockV3Aggregator.constructor confirmed Block: 1 Gas used: 430695 (3.59%)
MockV3Aggregator deployed at: 0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87
Mocks Deployed!
Transaction sent: 0x40bee6230d1f0b40935e0e86ae575da09da93e778b3d972a21b5fd1e93706b09
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 1
FundMe.constructor confirmed Block: 2 Gas used: 387021 (3.23%)
FundMe deployed at: 0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6
Contract deployed to 0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6
Terminating local RPC client...
I've tried:
- Add this code to the .yaml file per brownie webdocs instructions
development: host: http://127.0.0.1 reverting_tx_gas_limit: 6721975 test_rpc: cmd: ganache-cli port: 8545 gas_limit: 6721975 accounts: 10 evm_version: petersburg mnemonic: brownie
ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=7545)
Hi,there:
At youtube freedcodecamp 5:41:17 ,when tried to deploy to ganache-local,pop out these error information
ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=7545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd62639d700>: Failed to establish a new connection: [Errno 61] Connection refused'))
full information as:
BronieFundMe2022Project is the active project.
Running 'scripts/deploy.py::main'...
The active network is ganache-local
Deploying Mocks....
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 27, in main
deploy_fund_me()
File "./scripts/deploy.py", line 16, in deploy_fund_me
deploy_mocks()
File "./scripts/helpful_scripts.py", line 20, in deploy_mocks
MockV3Aggregator.deploy(DECIMALS,Web3.toWei(STARTING_PRICE,"ether"),{"from":get_account()})
File "brownie/network/contract.py", line 528, in __call__
return tx["from"].deploy(
File "brownie/network/account.py", line 510, in deploy
receipt, exc = self._make_transaction(
File "brownie/network/account.py", line 720, in _make_transaction
gas_price, gas_strategy, gas_iter = self._gas_price(gas_price)
File "brownie/network/account.py", line 456, in _gas_price
return web3.eth.generate_gas_price(), None, None
File "web3/eth.py", line 877, in generate_gas_price
return self._generate_gas_price(transaction_params)
File "web3/eth.py", line 173, in _generate_gas_price
return self.gasPriceStrategy(self.web3, transaction_params)
File "web3/gas_strategies/rpc.py", line 20, in rpc_gas_price_strategy
return web3.manager.request_blocking(RPC.eth_gasPrice, [])
File "web3/manager.py", line 197, in request_blocking
response = self._make_request(method, params)
File "web3/manager.py", line 150, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/gas_price_strategy.py", line 90, in middleware
return make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/attrdict.py", line 33, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/buffered_gas_estimate.py", line 40, in middleware
return make_request(method, params)
File "web3/middleware/exception_retry_request.py", line 105, in middleware
return make_request(method, params)
File "web3/providers/rpc.py", line 88, in make_request
raw_response = make_post_request(
File "web3/_utils/request.py", line 48, in make_post_request
response = session.post(endpoint_uri, data=data, *args, **kwargs) # type: ignore
File "requests/sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=7545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd62639d700>: Failed to establish a new connection: [Errno 61] Connection refused'))
from brownie import FundMe,network,config,MockV3Aggregator
from scripts.helpful_scripts import (deploy_mocks, get_account,LOCAL_BLOCKCHAIN_ENVIRONMENT)
def deploy_fund_me():
account = get_account()
# pass the price feed address to our fundme contract
# if we are on a persistent network like rinkeby, use the associated address
# otherwise, deploy mocks
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENT:
price_feed_address = config["network"][network_showactive()]["eth_usd_price_feed"]
else:
deploy_mocks()
price_feed_address = MockV3Aggregator[-1].address
fund_me = FundMe.deploy(
price_feed_address,
{"from":account},
publish_source=config["networks"][network.show_active()].get("verify"),
)
print(f"The contract deploy to {fund_me.address}")
def main():
deploy_fund_me()
Lesson 6: "FAILED test_fund_me.py::test_can_fun_and_withdraw
After connecting to alchemy, everything worked fine up until this error.
Went through and checked and even copy pasted my code from the files on here.
Any ideas? I know it's going to be something stupid on my end. Here's my code: from scripts.helpful_scripts import get_account, LOCAL_BLOCKCHAIN_ENVIRONMENTS
from scripts.deploy import deploy_fund_me
from brownie import network, accounts, exceptions
import pytest
def test_can_fund_and_withdraw():
account = get_account()
fund_me = deploy_fund_me()
entrance_fee = fund_me.getEntranceFee() + 100
tx = fund_me.fund({"from": account, "value": entrance_fee})
tx.wait(1)
assert fund_me.addressToAmountFunded(account.address) == entrance_fee
tx2 = fund_me.withdraw({"from": account})
tx2.wait(1)
assert fund_me.addressToAmountFunded(account.address) == 0
def test_only_owner_can_withdraw():
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip("only for local testing")
fund_me = deploy_fund_me()
bad_actor = accounts.add()
with pytest.raises(exceptions.VirtualMachineError):
fund_me.withdraw({"from": bad_actor})
Any and all help appreciated!
compile error
CompilerError: solc returned the following errors:
contracts/FundMe.sol:5:1: ParserError: Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
^--------------------------------------------------------------------------^
contracts/FundMe.sol:6:1: ParserError: Source "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
^------------------------------------------------------------------^
Issue with compiler version at around 5:11:00 in the video
pragma solidity 0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
No matter what I do, it either shows up as the compiler version being wrong (telling me it needs a different compiler version different to what I have set in the settings.json) or the two links are underlined in red and give me a "not found: file callback not supported" error. I fix one, the other gives me an error. Endlessly.
I've tried changing local and global compiler versions for everything.
I've tried every single solution I've found via googling it,
not working.
What am I doing wrong here? Or is one of these links broken...
Lesson 6: FAILED tests/test_fund_me.py::test_can_fund_and_withdraw - AttributeError: 'int' objec...
I was doing the Patrick Collins tutorial link and got this error and I got this error: FAILED tests/test_fund_me.py::test_can_fund_and_withdraw - AttributeError: 'int' objec..
when I was running brownie test
Any help is appreciated.
My files:
test_fund_me.py
from scripts.helpful_scripts import get_account
from scripts.deploy import deploy_fund_me
def test_can_fund_and_withdraw():
account = get_account()
fund_me = deploy_fund_me()
entrance_fee = fund_me.getEntranceFee()
tx = fund_me.fund({"from": account, "value": entrance_fee})
tx.wait(1)
assert fund_me.addressToAmountFunded(account.address) == entrance_fee
tx2 = fund_me.withdraw({"from": account})
tx2.wait(1)
assert fund_me.addressToAmountFunded(account.address) == 0
fund_and_withdraw.py
from brownie import FundMe
from scripts.helpful_scripts import get_account
def fund():
fund_me = FundMe[-1]
account = get_account()
entrance_fee = fund_me.getEntranceFee()
print(entrance_fee)
print(f"The current entry fee is {entrance_fee}")
print("Funding")
fund_me.fund({"from": account, "value": entrance_fee})
def withdraw():
fund_me = FundMe[-1]
account = get_account()
fund_me.withdraw({"from": account})
def main():
fund()
withdraw()
deploy.py
from brownie import FundMe, MockV3Aggregator, network, config
from scripts.helpful_scripts import (
get_account,
deploy_mocks,
LOCAL_BLOCKCHAIN_ENVIRONMENTS,
)
def deploy_fund_me():
account = get_account()
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
price_feed_address = config["networks"][network.show_active()][
"eth_usd_price_feed"
]
else:
deploy_mocks()
price_feed_address = MockV3Aggregator[-1].address
fund_me = FundMe.deploy(
price_feed_address,
{"from": account},
publish_source=config["networks"][network.show_active()].get("verify"),
)
print(f"Contract deployed to {fund_me.address}")
return fund_me
def main():
deploy_fund_me()
helpfull_scripts.py
from brownie import network, config, accounts, MockV3Aggregator
from web3 import Web3
LOCAL_BLOCKCHAIN_ENVIRONMENTS = ["development", "ganache-local"]
DECIMALS = 8
STARTING_PRICE = 200000000
def get_account():
if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
return accounts[0]
else:
return accounts.add(config["wallets"]["from_key"])
def deploy_mocks():
print(f"The active network is {network.show_active()}")
print(f"Deploying Mocks...")
if len(MockV3Aggregator) <= 0:
MockV3Aggregator.deploy(
DECIMALS, Web3.toWei(DECIMALS, STARTING_PRICE), {"from": get_account()}
)
print("Mocks Deployed!")
FundMe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
contract FundMe {
using SafeMathChainlink for uint256;
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
function fund() public payable {
uint256 mimimumUSD = 50 * 10**18;
require(
getConversionRate(msg.value) >= mimimumUSD,
"You need to spend more ETH!"
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
return priceFeed.version();
}
function getPrice() public view returns (uint256) {
(, int256 answer, , , ) = priceFeed.latestRoundData();
return uint256(answer * 10000000000);
}
// 1000000000
function getConversionRate(uint256 ethAmount)
public
view
returns (uint256)
{
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
return ethAmountInUsd;
}
function getEntranceFee() public view returns (uint256) {
// minimumUSD
uint256 minimumUSD = 50 * 10**18;
uint256 price = getPrice();
uint256 precision = 1 * 10**18;
// return (minimumUSD * precision) / price;
// We fixed a rounding error found in the video by adding one!
return ((minimumUSD * precision) / price) + 1;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function withdraw() public payable onlyOwner {
msg.sender.transfer(address(this).balance);
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
}
}
brownie-config.yalm
dependencies:
# - <organization/repo>@<version>
- smartcontractkit/[email protected]
compiler:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected]'
dotenv: .env
networks:
rinkeby:
eth_usd_price_feed: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'
verify: True
development:
verify: False
ganache-local:
verify: False
wallets:
from_key: ${PRIVATE_KEY}
I also have .env file with export PRIVATE_KEY
and export WEB3_INFURA_PROJECT_ID
Test Failed
test_only_owner_can_withdraw() doesnt work with Ganache UI v2.5.4
This is just to inform future learners to save them time;
As title says the test functiontest_only_owner_can_withdraw()
in this tutorial doesnt work in Ganache UI, and gives this error:
E ValueError: Execution reverted during call: 'VM Exception while processing transaction: revert'. This transaction will likely revert. If you wish to broadcast, include `allow_revert:True` as a transaction parameter.
Based on the comment here Ive found out that it works with ganache-cli
.
TypeError: Interfaces cannot inherit. interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
I keep getting this error when i try to compile. I tried shifting versions, but to no use. Please help thanks
(Mainnet-Fork) RPCProcessError: Unable to launch local RPC client.
brownie console --network mainnet-fork
(removed project id for infura project)
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum
FundMeProject is the active project.
Launching 'ganache-cli.cmd --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/projectid --gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'...
File "C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\_cli\__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\_cli\console.py", line 58, in main
network.connect(CONFIG.argv["network"])
File "C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\main.py", line 50, in connect
rpc.launch(active["cmd"], **active["cmd_settings"])
File "C:\Users\soodr\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\rpc\__init__.py", line 93, in launch
raise RPCProcessError(cmd, uri)
RPCProcessError: Unable to launch local RPC client.
Command: ganache-cli
URI: http://127.0.0.1:8545
constructor sequece
Running 'scripts\deploy.py::main'...
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie_cli\run.py", line 51, in main
return_value, frame = run(
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\project\scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File ".\scripts\deploy.py", line 14, in main
deploy_fund_me()
File ".\scripts\deploy.py", line 8, in deploy_fund_me
fund_me = FundMe.deploy({"from": account})
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\contract.py", line 549, in call
return tx["from"].deploy(
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\account.py", line 509, in deploy
data = contract.deploy.encode_input(*args)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\contract.py", line 579, in encode_input
data = format_input(self.abi, args)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\convert\normalize.py", line 20, in format_input
raise type(e)(f"{abi['name']} {e}") from None
ValueError: constructor Sequence has incorrect length, expected 1 but got 0
IndexError: list index out of range
Whenever I run the above code I get an index error. Please help me out
@PatrickAlphaC
@cromewar
brownie test no test ran in 0.01s
Deploying ganache-local w/brownie: VM Exception while processing transaction: invalid opcode
Thanks for an amazing class Patrick. I taught myself to code 3 years ago and wish I did it 33 years ago! :)
Issue
I am going through brownie simple storage part of this course. The initial deploy,.py works properly, but I keeping getting some variation of invalid opcode and the transaction is reverting when I try to deploy to ganache-local. I am able to run the tests in this project to development/ganache-cli, but fail with ganache-local and Rinkeby.
I am experiencing the same issues as I am with my own code base. I decided to test with a clone of this repo as 'bss' and replacing .env files with my info and am experiencing the same issues. I'm on MacOS.
Steps to reproduce & Troubleshooting
- brownie compile -a. Compiles successfully.
Solc version: 0.6.12
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
Generating build data...
- smartcontractkit/[email protected]/AggregatorInterface
- smartcontractkit/[email protected]/AggregatorV2V3Interface
- smartcontractkit/[email protected]/AggregatorV3Interface
- smartcontractkit/[email protected]/SafeMathChainlink
- FundMe
- MockV3Aggregator
Project has been compiled. Build artifacts saved at /Users/davidandrews/Documents/Projects/Web3/bss/build/contracts
- Deploy ganache ui.
- Execute
brownie run scripts/deploy.py --network ganache-local
~/Documents/Projects/Web3/bss (main●●)$ brownie run scripts/deploy.py --network ganache-local
Brownie v1.17.1 - Python development framework for Ethereum
BssProject is the active project.
Running 'scripts/deploy.py::main'...
The active network is ganache-local
Deploying Mocks...
Transaction sent: 0xe7b501480f70836256dbdd37a159100198d1422897117777e33588d1b2e1a566
Gas price: 20.0 gwei Gas limit: 540226 Nonce: 0
MockV3Aggregator.constructor confirmed Block: 1 Gas used: 491115 (90.91%)
MockV3Aggregator deployed at: 0xF5F2B13A72901f1621d2CD9b382c1c513ac0724D
Mocks Deployed!
Transaction sent: 0xc5a26f42997e9c648ee4d12df1805746cd3ca6508c315747f9b836ce5fb39516
Gas price: 20.0 gwei Gas limit: 528696 Nonce: 1
FundMe.constructor confirmed Block: 2 Gas used: 480633 (90.91%)
FundMe deployed at: 0xEDa314a434Ef759d85F60a54804FdfdbEB26F179
Contract deployed to 0xEDa314a434Ef759d85F60a54804FdfdbEB26F179
- Execute:
brownie run scripts/fund_and_withdraw.py --network ganache-local
BssProject is the active project.
Running 'scripts/fund_and_withdraw.py::main'...
25000000000000000
The current entry fee is 25000000000000000
Funding
Transaction sent: 0xffd686e74b439f0afff97ba5ab77ce31a48a66a6f2710d123b3cf37bc8b8bade
Gas price: 20.0 gwei Gas limit: 94207 Nonce: 2
FundMe.fund confirmed Block: 3 Gas used: 85643 (90.91%)
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/fund_and_withdraw.py", line 23, in main
withdraw()
File "./scripts/fund_and_withdraw.py", line 18, in withdraw
fund_me.withdraw({"from": account})
File "brownie/network/contract.py", line 1625, in __call__
return self.transact(*args)
File "brownie/network/contract.py", line 1498, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 644, in transfer
receipt, exc = self._make_transaction(
File "brownie/network/account.py", line 727, in _make_transaction
raise VirtualMachineError(e) from None
File "brownie/exceptions.py", line 121, in __init__
raise ValueError(str(exc)) from None
ValueError: Gas estimation failed: 'execution reverted: VM Exception while processing transaction: invalid opcode'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.
- Add gas_limit param to
fund_me.withdraw({"from": account})
->fund_me.withdraw({"from": account, 'gas_limit': 6721975})
Brownie v1.17.1 - Python development framework for Ethereum
BssProject is the active project.
Running 'scripts/fund_and_withdraw.py::main'...
25000000000000000
The current entry fee is 25000000000000000
Funding
Transaction sent: 0x996f97219b9c8cf1dd3f88753adf4c94335d27d1784972b976c550cea5f13c6d
Gas price: 20.0 gwei Gas limit: 61207 Nonce: 3
FundMe.fund confirmed Block: 4 Gas used: 55643 (90.91%)
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/fund_and_withdraw.py", line 24, in main
withdraw()
File "./scripts/fund_and_withdraw.py", line 19, in withdraw
fund_me.withdraw({"from": account, 'gas_limit': 6721975})
File "brownie/network/contract.py", line 1625, in __call__
return self.transact(*args)
File "brownie/network/contract.py", line 1498, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 644, in transfer
receipt, exc = self._make_transaction(
File "brownie/network/account.py", line 752, in _make_transaction
exc = VirtualMachineError(e)
File "brownie/exceptions.py", line 121, in __init__
raise ValueError(str(exc)) from None
ValueError: Execution reverted during call: 'execution reverted: VM Exception while processing transaction: invalid opcode'. This transaction will likely revert. If you wish to broadcast, include `allow_revert:True` as a transaction parameter.
- I've also tried deleting build artifacts & redeploying ganache ui.
Environment
Brownie v.1.17.1
Ganache CLI v6.12.2 (ganache-core: 2.13.2)
Node v16.8.0
Npm v7.21.0
Truffle v5.0.22
The only part of the code that has been changed from the repo is adding the gas_limit. Still happy to share the code if request. For the life of me, I can't figure what invalid opcode is causing this to revert . . . Any help would be greatly appreciated!
Thanks in advance!
@GratefulDave
account not accessible through brownie accounts while using --network ganache-local
(eth-brownie) PS C:\Users\lucky\Desktop\Investing\Courses\Solidity\demos\brownie_fund_me> brownie run scripts/deploy.py --network ganache-local
INFO: Could not find files for the given pattern(s).
Brownie v1.18.1 - Python development framework for Ethereum
BrownieFundMeProject is the active project.
Running '\Users\lucky\Desktop\Investing\Courses\Solidity\demos\brownie_fund_me\scripts\deploy.py::main'...
File "C:\Users\lucky.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 51, in main
return_value, frame = run(
File "C:\Users\lucky.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "\Users\lucky\Desktop\Investing\Courses\Solidity\demos\brownie_fund_me\scripts\deploy.py", line 31, in main
deploy_fund_me()
File "\Users\lucky\Desktop\Investing\Courses\Solidity\demos\brownie_fund_me\scripts\deploy.py", line 10, in deploy_fund_me
account = get_account()
File ".\scripts\helpful_scripts.py", line 12, in get_account
return accounts[0]
File "C:\Users\lucky.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py", line 115, in getitem
return self._accounts[key]
IndexError: list index out of range
I can run the chain locally and on the rinkeby testnet, but when I run it using --network ganache-local, it is throwing this error. I think it is not able to get the account address.
Testing errors
first of all thanks you @PatrickAlphaC I am learning sooo much from your course, I can say ha this is course is a game changer for me. I changed my mindset and many things in my life.......Keep it up. God bless you..
while testing in lesson 6 there are some errors showing I am quite new to blockchain please can you take a look at it
I don't understand where i am doing this wrong.
TypeError: argument of type 'NoneType' is not iterable
I'm getting this error when I input "brownie run scripts/deploy.py"
test_only_owner_can_withdraw throws AttributeError instead of expected VM exception
Great lesson.
I'm testing with a clone of your repo.
I ran brownie test -k test_only_owner_can_withdraw --network development
and saw an unexpected error:
> tx = fund_me.withdraw({"from": bad_actor})
E AttributeError: 'NoneType' object has no attribute '_with_attr'
Brownie v1.17.1 - Python development framework for Ethereum
platform darwin -- Python 3.9.8, pytest-6.2.5, py-1.10.0
Unable to Compile With MockV3Aggregator
My error:
brownie compile
Brownie v1.16.4 - Python development framework for Ethereum
New compatible solc version available: 0.6.0
Compiling contracts...
Solc version: 0.6.0
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
/Users/teryanarmen/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:38: TypeError: Interfaces cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-----------------^
/Users/teryanarmen/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:59: TypeError: Interfaces cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-------------------^
Issue With fund_and_withdraw.py Script
** GREAT tutorial thus far !!!**
The issue seems to be centered around the getEntranceFee function and I can not figure out what the issue is. Any assistance would be greatly appreciated.
Code
https://github.com/xosemanolo/brownie_fund_me
- brownie run scripts/deploy.py --network ganache-local
works well with following message:
Brownie v1.17.1 - Python development framework for Ethereum
BrownieFundMeProject is the active project.
Running 'scripts/deploy.py::main'...
The Active Network is ganache-local
Deploying Mocks...
Mock Deployed!
price feed address
0x1f35e1a93F5bA09A21D1de57C17957404D3f427B
Transaction sent: 0xb32c2a81f5a1547a2031afea6b82e82873050062a59a45b9c50c4d4c6928453b
Gas price: 20.0 gwei Gas limit: 424483 Nonce: 9
FundMe.constructor confirmed Block: 10 Gas used: 385894 (90.91%)
FundMe deployed at: 0xf62EFFb0E950177b281C2D883b820050B343a81e
Contract deployed to 0xf62EFFb0E950177b281C2D883b820050B343a81e
- brownie run scripts/fund_and_withdraw.py --network ganache-local
running into an issue with following message:
Brownie v1.17.1 - Python development framework for Ethereum
BrownieFundMeProject is the active project.
Running 'scripts/fund_and_withdraw.py::main'...
0xf62EFFb0E950177b281C2D883b820050B343a81e
0x4e0826D612afCe0868b7025aA975C304c27A54Aa
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/fund_and_withdraw.py", line 15, in main
fund()
File "./scripts/fund_and_withdraw.py", line 10, in fund
entrance_fee = fund_me.getEntranceFee()
File "brownie/network/multicall.py", line 115, in _proxy_call
result = ContractCall.__call__(*args, **kwargs) # type: ignore
File "brownie/network/contract.py", line 1661, in __call__
return self.call(*args, block_identifier=block_identifier)
File "brownie/network/contract.py", line 1457, in call
raise VirtualMachineError(e) from None
File "brownie/exceptions.py", line 121, in __init__
raise ValueError(str(exc)) from None
ValueError: execution reverted: VM Exception while processing transaction: revert
Invalid API Key
Hi, when I followed "brownie_fund_me" to verify my smart contract in Rinkeby. I got an Invalid API key error.
I have double checked all the detail in the code.
I have already set export ETHERSCAN_TOKEN=<MY_API_KEY> in .env and dotenv: .env in config file
I have already set fund_me = FundMe.deploy({"from":account},publish_source=True)
I have even checked pubilish_source() function in brownie and confirmed the URL is https://api-rinkeby.etherscan.io/api
And I also checked my API key: it was correct as it is copied directly from etherscan. I even created 2 API key, but neither of them worked.
brownie.exceptions.VirtualMachineError: revert in test_fund_me.py
I'm experiencing the above error even though I have added the code to handle the occurrence of such an error.
from scripts.helpful_scripts import get_account, LOCAL_BLOCKCHAIN_ENVIRONMENTS
from scripts.deploy import deploy_fund_me
from brownie import network, accounts, exceptions
import pytest
def test_can_fund_and_withdraw():
account = get_account()
fund_me = deploy_fund_me()
entrance_fee = fund_me.getEntranceFee() + 100
tx = fund_me.fund({"from": account, "value": entrance_fee})
tx.wait(1)
assert fund_me.addressToAmountFunded(account.address) == entrance_fee
tx2 = fund_me.withdraw({"from": account})
tx2.wait(1)
assert fund_me.addressToAmountFunded(account.address) == 0
def test_only_owner_can_witdraw():
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip("only for local testing")
fund_me = deploy_fund_me()
bad_actor = accounts.add()
with pytest.raises(exceptions.VirtualMachineError):
fund_me.withdraw({"from": bad_actor})
Error:
FAILED tests/test_fund_me.py::test_can_fund_and_withdraw - brownie.exceptions.VirtualMachineError: revert
Would appreciate any advice on how I can fix this.
TypeError: 'ContractContainer' object is not callable
Lesson 6: ValueError: execution reverted: VM Exception while processing transaction: revert
I am getting this error when attempting to run
brownie run scripts/fund_and_withdraw.py --network ganache-local
based on this response on ethereum.stackexchange it seems like the issue is with the price returned by the MockV3Aggregator making the getPrice() function return a value less than 1. StackExchange link
Is there a way to alter either the getPrice() function to include an "if < 0 return 1" or the MockV3Aggregator code?
TypeError: 'NoneType' object is not subscriptable
ConnectionError: Status 404 when getting package versions from Github: 'Not Found'
While following the freecodecamp tutorial, at 5:11:04 I got this error. Please do help me out.
@PatrickAlphaC
@MeLlamoValen
@cromewar
@7xAquarius
After running brownie compile, I got this
RESULT:
INFO: Could not find files for the given pattern(s).
Brownie v1.19.1 - Python development framework for Ethereum
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli_main_.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\compile.py", line 50, in main
proj = project.load()
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 780, in load
return Project(name, project_path)
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 188, in init
self.load()
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 257, in load
self._compile(changed, self._compiler_config, False)
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 90, in _compile
_install_dependencies(self._path)
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 786, in _install_dependencies
install_package(package_id)
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 808, in install_package
return _install_from_github(package_id)
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 871, in _install_from_github
download_url = _get_download_url_from_tag(org, repo, version, headers)
File "C:\Users\USER.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 947, in _get_download_url_from_tag\main.py", line 947, in _get_download_url_from_tag
raise ConnectionError(msg)
ConnectionError: Status 404 when getting package versions from Github: 'Not Found'
Missing or forbidden.
If this issue persists, generate a Github API token and store it as the environment variable GITHUB_TOKEN
:
https://github.blog/2013-05-16-personal-api-tokens/
error while trying to run with ganache-local network
CompilerError
CompilerError: solc returned the following errors:
contracts/FundMe.sol:34:1: ParserError: Function, variable, struct or modifier declaration expected.
Lesson 6 MockV3Aggregato Error
deploy on mainnet-fork
HI
i have successfully added mainnet-fork-dev by an alchemyapi app with this code in terminal:
brownie networks add development mainnet-fork-dev cmd=ganache-cli host=http://127.0.0.1 fork=https://eth-mainnet.alchemyapi.io/v2/QRAkGZCSGKYx-n2HNjpAys6qa5BugcV9 accounts=10 mnemonic=brownie port=8545
however when i try to deploy on mainnet-fork-dev with this code in terminal:
brownie run scripts/deploy.py --network mainnet-fork-dev
i dont get any thing! no Error no nothing, its looks like it cant even finish the deploy all i get is this:
_Brownie v1.16.4 - Python development framework for Ethereum
BrownieFundMeProject is the active project.
Launching 'ganache-cli.cmd --accounts 10 --fork https://eth-mainnet.alchemyapi.io/v2/QRAkGZCSGKYx-n2HNjpAys6qa5BugcV9 --mnemonic brownie --port 8545 --hardfork istanbul'...
_
and i cant do anything else until i trash the teminal and start a new one!
any thoughts?!
Key Error
I always get the same error, and don't know why, I checked all the code, there is no error
BrownieFundMeProject is the active project.
File "C:\Users\Alex_Chen.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli_main_.py", line 64, in main
importlib.import_module(f"brownie.cli.{cmd}").main()
File "C:\Users\Alex_Chen.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 45, in main
network.connect(CONFIG.argv["network"])
File "C:\Users\Alex_Chen.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\main.py", line 31, in connect
active = CONFIG.set_active_network(network)
File "C:\Users\Alex_Chen.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_config.py", line 76, in set_active_network
network = copy.deepcopy(self.networks[id])
KeyError: 'ganache-local'
Brownie not detecting Ganache
5:37:00ish
brownie didn't detect ganache when deploying. but after changing the PORT NUMBER to 8545 and the NETWORK ID to 1337 in ganache settings, it worked.
thought i'd share this error.
IndexError: list index out of range
TypeError: argument of type 'NoneType' is not iterable
ValueError: sender doesn't have enough funds to send tx. The upfront cost is: 9475020000000000 and the sender's account only has: 0
need to set GITHUB_TOKEN in brownie but don't know how
I'm using VPN to connect to the internet (because GitHub is not accessible in my country)
when I run > brownie compile
I get
ConnectionError: Status 404 when getting package versions from Github: 'Not Found'
Missing or forbidden.
If this issue persists, generate a Github API token and store it as the environment variable `GITHUB_TOKEN`:
https://github.blog/2013-05-16-personal-api-tokens/
I think it caused by github rejecting my connection
I've tried to set github_token in dotenv like this:
export GITHUB_TOKEN = 'ghp_00000000000000000000000000000000000000'
also
but getting the same error
also echo $GITHUB_TOKEN
[is blank]
in the brownie docs: https://eth-brownie.readthedocs.io/_/downloads/en/stable/pdf/ page 33 installing from GitHub said :
It is possible to install from a private Github repository using an API access token like a personal access token. This can be provided to Brownie via the GITHUB_TOKEN environment variable in the form of username:ghp_token_secret. See also https://docs.github.com/en/rest/overview/
but I don't know what to do in .env or brownie-config.yaml
thank you in advance
Error in brownie test
As explained by Patrick, we need to close the Ganache-UI before writing brownie test
in the terminal.
So did I keeping everything same.....and got a massive error for some reason where the main error message was:
ValueError: sender doesn't have enough funds to send tx. The upfront cost is: 25000000000000000 and the sender's account only has: 0
Error screen part 1:
Error screen part 2:
My test_fund_me.py
code (until now) looks like this:
from scripts.helpful_scripts import get_account
from scripts.deploy import deploy_fund_me
import pytest
def test_fund_and_withdraw():
account = get_account()
fund_me = deploy_fund_me()
entrance_fee = fund_me.getEntranceFee()
tx1 = fund_me.fund({"from": account, "value": entrance_fee})
tx1.wait(1)
assert fund_me.addressToAmountFunded(account.address) == entrance_fee
tx2 = fund_me.withdraw({"from": account})
tx2.wait(1)
assert fund_me.addressToAmountFunded(account.address) == 0
I'm a complete newbie in this field and thus have very limited knowledge about it.
Thanks in advance
KeyError: 'ganache-local'
when i am running this command brownie run scripts/deploy.py --network ganache-local it always throw an error like {
KeyError: 'ganache-local'
}
2500000 - Entrance fee; expected: 25000000000000000
Video Timestamp: https://youtu.be/M576WGiDBdQ?t=20714
Running the script of 'fund_and_withdraw.py' gave an output of 2500000, when the expected output by Patrick was 25000000000000000 in the video.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.