0

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?

1 Answer 1

0

you should try this

return PriceFeed(address(lottery.price_feed));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.