Skip to main content
Shared objects enable multiple users to interact with the same on-chain state. They’re essential for protocols like DEXs, lending platforms, and games.

Shared vs Owned Objects

Owned objects:
  • Owned by a single address
  • Fast - no consensus required
  • Suitable for wallets, NFTs, personal items
Shared objects:
  • Accessible by anyone
  • Require consensus
  • Necessary for multi-user applications

Creating Shared Objects

Use transfer::share_object to make an object shared:

Real Example: Cash Register

From examples/move/transfer-to-object/shared-no-tto:

Access Control Patterns

Owner-only functions

Role-based access

Capability-based access

Flash Loan Example

From examples/move/flash_lender:

Testing Shared Objects

Performance Considerations

Minimize shared object usage

Use owned objects when possible:

Avoid contention

Design to minimize concurrent access:

Common Patterns

Registry pattern

Pool pattern

Best Practices

1. Use shared objects sparingly

Only when multiple users need concurrent access.

2. Implement proper access control

Always validate callers:

3. Document shared object semantics

4. Consider object composition

Combine shared and owned objects:

Next Steps