I have a contract Lottery.sol which deploys a contract PriceFeed.
In Lottery.sol :
contract PriceFeed {
.....
}
contract Lottery {
PriceFeed public price_feed = new PriceFeed();
}
In my Foundry deployment script which imports Lottery.sol, I made run() to return a (contract PriceFeed) as a test to see where price_feed gets deployed.
In Deploy.s.sol :
......
contract Deploy is Script {
function run() external returns (PriceFeed) {
vm.startBroadcast();
Lottery lottery = new Lottery();
vm.stopBroadcast();
return lottery.price_feed;
}
}
I get the following error when trying to build the project with forge:
Return argument type function () view external returns (contract PriceFeed) is not implicitly convertible to expected type (type of first return variable) contract PriceFeed.
How can I resolve this?
Dec 21, 2023, 9:18 AM
When you call it from outside it's a getter function.
lottery.price_feed();
lottery.price_feed();
Dec 21, 2023, 10:44 AM
Thank you.
I would like to learn more about this behavior, is there a section in the docs you can refer me to?
I would like to learn more about this behavior, is there a section in the docs you can refer me to?
Dec 21, 2023, 10:57 AM