Hello, I am switching from Solidity to Move, and I am facing a lot of mental blocks getting the full hang of Sui architecture. I have read the docs about Sui being object-centered in regards to everything being an object on chain. A few of my biggest questions right now are:
-
How does one maintain a particular state on-chain? I get that it can be maintained as an object with its ID being used to refer to it. Let’s say a setter function is being used to modify that object, so each time the setter function needs to be called, the id of that object needs to be retrieved off-chain and passed to the setter function through the txn?
-
init functions: They are the closest to what a constructor is in Solidity, aren’t they? Let’s say I initialize a few table through the init function, and insertions and removals in it happen through a few public functions. Again the same issue, is the object ID of the table required to be passed to those functions each time they are called?
-
visibility modifiers: I am so confused regarding this. All the beginner examples I followed had normal structs declared (with no visibility modifiers whatsoever). So I created a new Sui project with
$ sui move new my_first_package
and just building the already provided example threw errors regarding visibility. I followed thishttps://github.com/MystenLabs/sui/issues/17087
(the forum doesn’t allow me to add links yet) to resolve it, but still did not made much sense. What are the read and write permissions for each object type ,i.e. Shared vs owned? Also is it possible to directly manipulate the object through its ID ? or is it only possible through the functions in the same module the struct was created from? -
Is there any concept of approvals in coins, similar to ERC20 approvals?
I know this is a very long post, but it would be very helpful, for me and more devs who come across similar issues, if someone could clear these doubts. Thanks in advance.