I am following Patrick Alpha's brownie tutorial using python visual studio: https://www.youtube.com/watch?v=M576WGiDBdQ (at around the 5:57 mark). I am using brownie and am trying to run my python deploy script : brownie run scripts/deploy.py --network mainnet-fork.
When I run it, I get : ValueError: constructor '{'eth_usd_price_feed': '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', 'verify': False}' - '{'eth_usd_price_feed': '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', 'verify': False}' is not a valid ETH address Terminating local RPC client...
"The desired output is getting another value error telling me I don't have enough gas......"
Here are the relevant contracts and scripts...
This is my brownie-config.yam; 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}
I copied this directly from the github..
Now, here is the 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;
// 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);
}
}
Here is the helpful script
from brownie import network, config, accounts, MockV3Aggregator
from web3 import Web3
LOCAL_BLOCKCHAIN_ENVIRONMENTS = [ "development", "ganache-local"]
FORKED_LOCAL_ENVIRONMENTS = ["mainnet-fork"]
DECIMALS = 8
STARTING_PRICE = 200000000000
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: #list of all v3 aggregators we've deployed
MockV3Aggregator.deploy(DECIMALS, STARTING_PRICE, {"from": get_account()})
print("Mocks Deployed") #use tge most recently deployed mock agregator