Factory Contracts
Last updated
Was this helpful?
Last updated
Was this helpful?
Factory contracts are contracts that create other contracts. They are useful for:
Dividing your app into parts, each with different responsibilities.
Extending the scope of your app by dynamically adding a piece of functionality.
Managing different parts of the app from a single location, etc.
Here are some examples of active projects that use factory contracts:
, where a Factory contract a new Child contract for every new pair supported on the exchange. (Cosmwasm v0.10).
, where a Parent "Bank" Contract which manages the funds a single "Game" Contract which manages the game logic. (Cosmwasm v0.10).
After the child contract is stored on chain, you can instantiate child contracts from the factory in the following manner:
Assume the child contract expects the following instantiate message:
To instantiate the child contract, you can send a from the parent with the child's instantiate message:
If you don't care about the reply, you can send a regular message instead: