This is more of a general discussion then a direct question.
I am trying to find a way for a smart contract to be identified somehow by another one.
My final goal is to allow some functions in "contract1" to only be executed by contracts that have been created following the template of "contract2" but may contain different kind of data.
A first though was, could I keep a sort of hash or key in "contract2" and send it over to "contract1" following a bit the example of the transfer function in ERC223:
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
if (isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
}
basically adding one more if function:
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
if (isContract(_to) && _data == *SECRETKEY*) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
}
But obviously the problem with this is that the key would need to be kept in clear and therefore not so secret after all.
Does anyone have any suggestions on how could I go about doing this ?