Check msg.sender
and reject unacceptable actors.
In Market
to protect foo()
- make sure msg.sender == reputation
.
Also in Market
- a function to update reputation
when you know the address.
Here's a little scribble to give you some ideas.
contract Market {
address reputation;
modifier onlyReputation {
require(msg.sender == reputation, "403");
_;
}
constructor(address reputation_) {
reputation = reputation_;
}
function foo() public onlyReputation {
// carry on
}
}
That is the general idea. You can add functions to edit/update the acceptable reputation
from time to time. You would want another variable, e.g. address owner
to specify who is allowed to do that.
Finally, if you want to coordinate the deployment and there is one Market for each Reputation, use the constructors
to configure everything on the fly.
In Reputation
:
Market market;);
constructor () {
market = new Market();
}
That way it will create one and know where it is. In Market
, recognize "the creator" as the one to trust.
address reputation;
constructor () {
reputation = msg.sender;
}
Hope it helps.