I'm trying to get getConversionRate() to return an ETH value for 100 by running this script:
from brownie import Donation, config, network, MockV3Aggregator
from scripts.helpful_scripts import (
LOCAL_BLOCKCHAIN_ENVIRONMENTS,
deploy_mocks,
get_account,
)
def deploy_donation():
account = get_account()
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
price_feed_address = config["networks"][network.show_active()][
"eth_usd_price_feed_address"
]
else:
deploy_mocks()
price_feed_address = MockV3Aggregator[-1].address
donation = Donation.deploy(
price_feed_address,
{"from": account},
)
print(f"Contract deployed to {donation.address}")
get_price = donation.getPrice()
print(f"The current price of ETH/USD is {get_price}")
get_conversion_rate = donation.getConversionRate(100)
print(get_conversion_rate)
return donation
def main():
deploy_donation()
for this smart contract:
// 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 Donation {
using SafeMathChainlink for uint256;
uint256 ethAmount;
address payable owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) public {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
function donate(uint256 _amount) public payable {
ethAmount = getConversionRate(_amount);
owner.transfer(ethAmount);
}
function getConversionRate(uint256 rawUSD) public view returns (uint256) {
uint256 ethPrice = getPrice();
uint256 ethValue = (rawUSD / ethPrice) * 1000000000000000000;
return ethValue;
}
function getPrice() public view returns (uint256) {
(, int256 answer, , , ) = priceFeed.latestRoundData();
return uint256(answer * 10000000000);
}
}
Please what is the problem with my script, how do i get it to return a converted value?