Post
Share your knowledge.
Store global variables in Move smart contract with shared objects
I'm working on a Move smart contract and struggling to store a global variable using a struct. I've been trying for hours but can't get it to work. Any tips or solutions?
- Move CLI
Answers
1In Move, there isn't a straightforward global storage concept as seen in other smart contract languages. Instead, you would use shared objects to store what resembles global data. You can store your 'global variable' inside a shared object. These objects are accessible globally as long as you know their unique identifiers. You can look into the Sui documentation for more guidance on how to set this up. Here's an example and further explanation: Shared Object Documentation.
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.