I already have searched for my question on Stack Overflow and on the documentation (https://docs.soliditylang.org/en/develop/contracts.html#visibility-and-getters), but I am not sure of the answer.
To better explain my answer, I have created an example:
pragma solidity ^0.8.17;
contract A{
bool public dummy;
function setDummy (bool x) public{
dummy = x;
}
function getDummy () public view returns(bool){
return dummy;
}
}
contract B {
A public aContract;
function initialize () public{
aContract = new A();
}
}
If I deploy B
and call initialize, I can see the address of aContract
. This means that I can interact with the aContract
(like calling setDummy
) without passing by B
.
I do not want this behavior!
I would like that only B
can call aContract
. Does make aContract
private solve this problem? Or I need to make some restriction like onlyOwner
on setDummy
?
I do not know if making aContract
private still leave some vulnerabilities.
Thank You!