docs/content/guides/developer/dev-cheat-sheet.mdx
Quick reference on best practices for Sui Network developers.
vector-backed collections (vector, VecSet, VecMap, PriorityQueue) with a known maximum size of ≤ 1000 items.
Table, Bag, ObjectBag, ObjectTable, LinkedTable) for any collection that allows third-party addition, larger collections, and collections of unknown size.vector-backed collection.f needs a payment in, for example, SUI from the caller, use fun f(payment: Coin<SUI>) not fun f(payment: &mut Coin<SUI>, amount: u64). This is safer for callers; they know exactly how much they are paying, and do not need to trust f to extract the right amount.P1 to P2, other packages and clients that depend on P1 will continue using P1. They do not auto-update to P2. Both dependent packages and client code must be explicitly updated to point at P2.prepare_message from any version of the Wormhole package to produce a MessageTicket while client code that sends the message must pass that MessageTicket into publish_message in the latest version of the package.
public function signatures cannot be deleted or changed, but public(friend) functions can. Use public(friend) or private visibility liberally unless you are exposing library functions that will live forever.struct types, change their definition or add new abilities via an upgrade. Introduce new types carefully as they will live forever.sui::test_scenario module to mimic multi-transaction, multi-sender test scenarios.std::unit_test module for assert_eq! and assert_ref_eq! macros for better test error messages.sui::test_utils module for black-hole function destroy.std::debug module for debug printing via print.sui move test --coverage to compute code coverage information for your tests, and sui move coverage source --module <name> to see uncovered lines highlighted in red. Push coverage all the way to 100% if feasible.signTransactionBlock API, then submit the transaction via a call to execute_transactionBlock on the app's full node, not use the wallet's signAndExecuteTransactionBlock API. This ensures read-after-write-consistency--reads from the app's full node will reflect writes from the transaction right away instead of waiting for a checkpoint.sui client command that crafts a transaction (e.g., sui client publish, sui client call) can accept the --serialize-output flag to output a base64 transaction to be signed.