Move.

Post

Share your knowledge.

Tawhid.
Jan 10, 2025
Expert Q&A

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
1
1
Share
Comments
.

Answers

1
Pluto Dev👽.
Jan 10 2025, 18:13

In 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.

0
Comments
.

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.

148Posts231Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignJune
We use cookies to ensure you get the best experience on our website.
More info