apps/docs/src/guide/contracts/configurable-constants.md
Sway introduces a powerful feature: configurable constants. When creating a contract, you can define constants, each assigned with a default value.
Before deploying the contract, you can then redefine the value for these constants, it can be all of them or as many as you need.
This feature provides flexibility for dynamic contract environments. It allows a high level of customization, leading to more efficient and adaptable smart contracts.
Below is an example of a contract in which we declare four configurable constants:
<<< @/../../docs/sway/echo-configurables/src/main.sw#configurable-constants-1{rust:line-numbers}
In this contract, the function echo_configurables returns the values of the configurable constants, which we'll use for demonstrating the setting of configurables via the SDK.
During contract deployment, you can define new values for any/all of the configurable constants. The example below shows setting of one configurable constant, while the others will have default values.
<<< @./snippets/configurable-constants.ts#setting-configurable-constant{ts:line-numbers}
Please note that when assigning new values for a Struct, all properties of the Struct must be defined. Failing to do so will result in an error:
<<< @./snippets/configurable-constants.ts#invalid-configurable{ts:line-numbers}