Hello, I have a question
Is it possible to set some default storage values during deployment?
like a constructor in solidity
Initial storage values can be specified in the storage
block itself as in:
storage {
x: u64 = 42,
s: MyStruct = MyStruct {
a: 6,
b: 8,
}
}
When deploying the contract via forc deploy
, then initial values are set as raw initial storage values with whatever keys the compiler chose for the variables above.
The raw initial slots are also emitted to a JSON file: out/debug/<project_name>-storage_slots.json
which can be used by the SDK.
For example, I want to declare the name of the token when I deploy the dapp to avoid changing the token contract every time before deployment. How I can do it?
configuration time constants may be what you are looking for
Yeah as @SwayStar123 said, you need configuration-time constants here. See an example here, and the documentation in Variables - The Sway Programming Language
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.