I have two contracts. #1 creates tokens and sends them to my address. #2 does some other stuff.
'#1 contains a reference to, say, 0xMyAddress (known in advance, of course) in order to grant it special permission for dealing with the tokens. It also needs to contain a similar reference to the address of contact #2.
Contract #2 needs to contain a reference to the address of contract #1, in order to know what tokens it's dealing with.
How do I reconcile this? I have to deploy each contract before I find out what its address will be, so I can't include #1's address in #2, while also including #2's address in #1.
Am I thinking along the right lines here:
Choose which contract will be deployed first, and in that one, include:
function set_otherContractAddress(address _address) public{
require(msg.sender == 0xMyAddress);
otherContractAddress = newVal;
}
Then I can deploy that contract, find out it's address, hard code that address into the other contract, deploy it and find out it's address, and then go back and add it to the first contract with that function ^
I hope that makes sense!