The contract address is a hash of the code's **stateInit**
.
If you change the initial storage of the contract, you are changing the future address of the contract. However, the future contract address is deterministic (known before you deploy), so you can pass the address to the storage, as part of the initializations of the contract.
For example, the Tact language down below shows how I can create a stateInit code to get Smart Contract address:
contract Example {
any_int: Int;
init() {
self.any_int = 0;
}
receive("A") {
let contractInit: StateInit = initOf TargetContract(self.any_int, 666);
send(SendParameters{
to: contractAddress(contractInit),
value: 0,
mode: 0 + 64 + 128,
bounce: false
});
}
}
contract TargetContract {
counter: Int;
balance: Int;
init(input_counter: Int, input_balance: Int){
self.counter = input_counter;
self.balance = input_balance;
}
receive(){
// empty, means do nothing when receive empty body message.
}
}
As you can see, we can change the parameters that the second contract needs to predetermine the contract address since we got the stateInit
code.
In FunC you can use string literals with a
tag. For example: "Ef8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzM0vF"a
More info: https://ton.org/docs/develop/func/literals_identifiers#string-literals