Constants are values that are bound to a name and cannot change. They are always immutable. In Rust, constants are declared with the const keyword. Unlike variables declared with the let keyword, constants must be annotated with their type.
Constants are valid for the entire length of the transaction. They are essentially inlined wherever they are used, meaning that their value is copied directly into whatever context invokes them.
Since their value is hardcoded, they can save on gas cost as their value does not need to be fetched from storage.
1Loading...1Loading...1Loading...1Loading...