Post
Share your knowledge.
Question about move attribute
Is there a list of move attributes (e.g #[test] #[expected_failure])
but not just for test but function attributes as well? I see #[syntax(index)] in 0x2::table::borrow. A table of definitions would be helpful.
- Sui
Answers
2Enums values don't have IDs and aren't stored like owned objects, they are more like wrapped objects, where their bytes are just stored as part of the object that contains them
There isn't an official all-in-one list of Move attributes, but you can still find most of the ones that matter by exploring the Sui Move codebase and documentation. You mainly use attributes like #[test]
, #[expected_failure]
, and #[test_only]
for testing, while others like #[entry]
and #[view]
control how a function behaves on-chain. For example, #[entry]
marks a public function that can be called in a transaction, and #[view]
means the function doesn’t change any state, making it safe for off-chain queries. When you see #[syntax(index)]
in 0x2::table::borrow
, that’s a low-level internal helper the Sui compiler uses to support sugar syntax like table[key]
— it's not meant for general use. Right now, the best way to understand all the attributes is by browsing the sui-framework source, checking modules like coin
, table
, and transfer
, and watching how attributes are applied there. For deeper behavior, you can also look at Move IR reference even though some attributes are Sui-specific and won’t show up there.
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- Why does BCS require exact field order for deserialization when Move structs have named fields?53
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution43
- Sui Transaction Failing: Objects Reserved for Another Transaction25
- How do ability constraints interact with dynamic fields in heterogeneous collections?05