contract Parent{
id: Int = 0;
init(){}
receive("new"){
self.id += 1;
let data = initOf Child(self.id);
self.forward(contractAddress(data), "init".asComment(), true, data);
}
}
contract Child{
id: Int;
init(id: Int){
self.id = id;
}
receive("init"){}
receive("deploy_random"){
let data = initOf Child(randomInt());
self.forward(contractAddress(data), "init".asComment(), true, data);
}
}
Under the hood, both Parent and Child contracts stores the code of Child smart contract in the system dictionary, because in both of them initOf Child() used.
But storing code of Child smart contract inside Child is useless because one can call MYCODEasm instruction to get it.
This approach would reduce not only storageFees, but also forwardFees when initializing new smart-contracts.
It is really useful feature for developing Jetton smart contracts (when one child deploys another child), which optimizes fees a lot.
The problem
Lets take a look on a 2 simple smart-contracts:
Under the hood, both Parent and Child contracts stores the code of
Child
smart contract in the system dictionary, because in both of theminitOf Child()
used.But storing code of
Child
smart contract insideChild
is useless because one can callMYCODE
asm instruction to get it.This approach would reduce not only storageFees, but also forwardFees when initializing new smart-contracts.
It is really useful feature for developing
Jetton
smart contracts (when one child deploys another child), which optimizes fees a lot.Feel free to argue to my point.