Skip to main content
Components can declare their own storage variables. When a contract uses a component, the component storage is merged with the contract storage. The storage layout is only determined by the variables names, so variables with the same name will collide.
In a future release, the #[substorage(v1)] will determine the storage layout based on the component as well, so collisions will be avoided.
A good practice is to prefix the component storage variables with the component name, as shown in the Switchable component example.

Example

Here’s an example of a collision on the switchable_value storage variable of the Switchable component. Interface:
Here’s the storage of the contract:
Both the contract and the component have a switchable_value storage variable, so they collide: