hi everybody!
I just want to store a BigUint constant that will be used in many functions of my Smart Contract. There are two ways of doing this:
- define a Rust constant of type u64 named RAY and in each function where it is needed declare let ray = BigUint::from(RAY)
- declare the BigUint once (in the constructor for example) and store it in a mapper. Retrieve the mapper value in every function the constant value is needed.
which approach is better?
If it's a constant that is general purpose, like the number "1" for NFT amount for example, then keep is as const. If it's something specific for your SC that might change, definitely in storage
If it's a constant that is general purpose, like the number "1" for NFT amount for example, then keep is as const. If it's something specific for your SC that might change, definitely in storage
Also, don't just call .get() in every function, pass it around as a reference