Move.

Post

Share your knowledge.

skywinder.
Dec 01, 2024
Expert Q&A

How can I store global variables in Move smart contracts effectively?

How can global variables be stored in Move smart contracts effectively?

  • Move CLI
  • Move
1
3
Share
Comments
.

Answers

3
Elvin CLONE .
Dec 2 2024, 20:08

In Move, there is no concept of traditional global storage. Instead, you can store global data using a shared object, which lets you encapsulate data that can be accessed across different modules or functions. This approach helps manage data similarly to global variables in other programming environments .

0
Best Answer
Comments
.
tomek.
Dec 1 2024, 22:06

The shared.move file in the Tic Tac Toe example provided by Sui showcases how a Game object is shared so both players can interact with it. The use of shared objects in this context allows global-like data sharing across different participants .

1
Comments
.
Raju.
Raju158
Dec 2 2024, 02:04

An example of using a shared object to store global data in a Move smart contract is demonstrated on the Sui documentation: transfer::share_object(Object { id: object::new(ctx), ... }). This method involves creating an object that has the key ability, allowing it to be part of Sui's global object pool .

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