Sui.

Post

Share your knowledge.

shamueely.
Jul 27, 2025
Expert Q&A

What’s the best way to handle concurrent transactions in Sui?

My dApp has multiple users interacting with the same object. How does Sui handle concurrency, and how can I avoid conflicts?

  • Sui
  • Move
2
10
Share
Comments
.

Answers

10
theking.
Jul 27 2025, 18:16

To handle concurrent transactions in Sui effectively, you need to understand how its object-centric data model works. Sui tracks ownership and access at the object level, not by accounts or contracts. This means if multiple users interact with the same object, and that object is owned (not shared or immutable), their transactions will conflict and fail if submitted at the same time.

To avoid this, you should design your dApp using shared objects where possible. Shared objects in Sui allow multiple users to interact without causing execution conflicts because they are versioned and support parallel execution through the Narwhal & Bullshark consensus engine.

Here’s how you can reduce concurrency issues:

  • Use has shared objects for entities that need concurrent access (e.g., game lobbies, pools, DAOs).
  • Minimize mutations to the same owned object. Instead, write data to dynamic fields or separate object instances per user.
  • When writing your Move modules, avoid bottlenecks by spreading logic across smaller, user-owned or transient objects.
  • Use programmable transactions to batch logic that would otherwise create race conditions.

If you’re using the TypeScript or Rust SDKs, structure your transaction blocks so that object access is clear and predictable. You can track object ownership with the sui_getObject or suix_getOwnedObjects API.

For more details on conflict resolution and concurrency design in Sui, read the official guide here: https://docs.sui.io/learn/concepts/ownership.

0
Best Answer
Comments
.
Ashford.
Jul 31 2025, 08:16

In Sui, handling concurrent transactions is managed through its unique object-based model and parallel transaction processing. Here's how Sui handles concurrency and what you can do to avoid conflicts when multiple users are interacting with the same object.

1. Sui's Object-based Model

Sui’s architecture is built on an object-based state model where each object (e.g., a token, NFT, or smart contract state) has a unique object ID. This means that rather than modifying global state like Ethereum, transactions in Sui modify individual objects. This approach allows for more efficient and scalable concurrency, as different objects can be updated in parallel, as long as there’s no conflict (i.e., multiple transactions trying to modify the same object).

2. Concurrency Handling in Sui

  • Parallel Transactions: Sui can execute transactions in parallel as long as they don't touch the same object. For example, if two transactions modify different objects (like transferring two different NFTs), they can run concurrently without issue.
  • Object Locking: When two transactions try to modify the same object, Sui serializes these transactions (one must wait for the other to complete). This ensures that state consistency is maintained and race conditions are avoided.

3. Avoiding Conflicts

To handle concurrent transactions effectively and avoid conflicts, you should focus on these key strategies:

a) Minimize Contention:

  • Ensure that different users interact with different objects whenever possible. This minimizes the chance that multiple users will attempt to modify the same object concurrently.
  • For example, if you're building a marketplace with NFTs, you should ensure that transactions related to different NFTs are independent and don’t conflict with each other.

b) Use Transaction Bundling:

  • You can bundle multiple operations into a single transaction if they modify related objects. This ensures that the state changes are atomic and occur in a controlled manner, reducing the risk of conflicts.
  • In Sui, this is done by creating a transaction block with multiple move calls.

Example:

const txn = new TransactionBlock();
txn.moveCall({
    target: '0x2::coin::transfer',
    arguments: [txn.pure(sender), txn.pure(receiver), txn.pure(amount)],
});
txn.moveCall({
    target: '0x2::coin::transfer',
    arguments: [txn.pure(sender2), txn.pure(receiver2), txn.pure(amount2)],
});

c) Check for Object Locks:

  • You can query the state of the object before performing actions to check if it is being modified by another transaction. This helps detect contention ahead of time.
  • Retry logic: If a conflict occurs, you can implement retry mechanisms in your application, which can automatically attempt to resubmit the transaction after a delay.

d) Use the TransactionBlock for Efficient Batch Execution:

  • Group related transactions together in a transaction block to ensure that they are executed atomically and to reduce conflicts.

e) Optimistic Concurrency Control:

  • For certain types of applications (like game mechanics or auction systems), you can implement optimistic concurrency control. This approach assumes that conflicts will rarely happen and lets transactions proceed without checking for conflicts. If a conflict does occur, the transaction is retried with updated data.

4. Best Practices to Handle Concurrent Transactions

Here are some best practices to minimize conflict and optimize concurrency:

a) Design with Object Ownership in Mind:

  • Ensure that users are modifying different objects in a way that reduces the likelihood of them trying to modify the same object. For example:

    • Tokens: Ensure that each token has a unique ID, and different users are always working with different tokens.
    • NFTs: For NFT marketplaces, ensure that each transaction targets a unique NFT and doesn’t collide with others.

b) Use Eventual Consistency:

  • For some dApps, you can leverage eventual consistency where you allow for some flexibility and let users interact concurrently, handling conflicts when they arise (e.g., retries or updates).

c) Monitor Transaction Conflicts:

  • Implement logging or monitoring to track where conflicts happen frequently. If you see patterns, consider restructuring how objects are interacted with or optimize your transaction workflows.

5. Error Handling and Retry Logic

If multiple users are attempting to interact with the same object, it is important to handle errors gracefully and implement retry logic in case of conflicts:

const retryTransaction = async (txn: TransactionBlock, retries = 3) => {
    let attempt = 0;
    while (attempt < retries) {
        try {
            const result = await suiClient.submitTransaction(txn);
            return result;
        } catch (error) {
            console.error(`Attempt ${attempt + 1} failed:`, error);
            attempt++;
            if (attempt >= retries) {
                throw new Error('Failed after multiple attempts');
            }
            await new Promise(res => setTimeout(res, 1000 * Math.pow(2, attempt))); // Exponential backoff
        }
    }
};

This retry mechanism ensures that your dApp will automatically retry failed transactions after waiting for a while, reducing the impact of temporary conflicts.

6. Transaction Simulation (Optional)

Before submitting a transaction, you can simulate it to check if there would be any conflicts or if it will be successfully executed. The Sui client provides simulation APIs that allow you to preview the transaction's success or failure without actually submitting it.

Example:

const simulationResult = await suiClient.simulateTransaction(txn);
console.log('Simulation Result:', simulationResult);

This allows you to detect issues before submitting, reducing the need for retries.

7. Sui SDK and CLI Tools

  • Sui CLI: You can also use the Sui CLI to simulate transactions, get object states, and see potential conflicts.
  • Sui SDK: For programmatic access to transaction simulation and conflict resolution, using the Sui SDK in JavaScript/TypeScript is ideal.

Conclusion

To handle concurrent transactions in Sui effectively:

  • Use transaction blocks and batch related operations to minimize conflicts.
  • Leverage parallel execution by ensuring transactions modify different objects.
  • Implement retry logic and conflict detection to handle situations where transactions try to modify the same object.
  • Use transaction simulation to pre-check for conflicts and reduce transaction failures.
  • Monitor and analyze transaction conflicts to optimize workflows.

By designing your dApp with these considerations, you can ensure smooth concurrency management and avoid conflicts when multiple users interact with the same object on Sui.

7
Comments
.
Thorfin.
Jul 31 2025, 14:03

Sui uses a unique approach with parallel execution and Move-based transactions. Each transaction operates on independent objects or locked groups of objects, allowing concurrency without conflicts. To avoid issues:

  1. Object-level locking: Sui locks objects during a transaction to prevent race conditions.
  2. Transaction grouping: Transactions that operate on the same object can be grouped, ensuring they are processed in order.
  3. Optimistic concurrency: Sui assumes that most transactions will succeed, only verifying conflicts during commit.

By designing your dApp with proper object isolation and transaction ordering, you can minimize conflicts and maximize parallelism.

7
Comments
.
Benjamin XDV.
Jul 29 2025, 13:42

Sui Concurrency Rules

  1. Shared Objects:

    • Use key + store structs with TxContext for atomic updates
    • Sui automatically sequences access (no conflicts)
  2. Owned Objects:

    • Parallelizable (no locks needed)

Best Practices

// 1. Design for shared access
struct SharedData has key, store {  
    id: UID,
    value: u64
}

// 2. Use PTBs for multi-object ops
let txb = TransactionBuilder::new();
txb.move_call(/* obj1 */);
txb.move_call(/* obj2 */); // Executed atomically

Conflict Avoidance

  • For high contention:

    public entry fun update(
        shared: &mut SharedData,  
        ctx: &mut TxContext  
    ) {
        // All changes are atomic
    }
    
  • For scale:
    Shard data (e.g., per-user sub-objects)

Sui handles the rest! No manual locking.

6
Comments
.
Owen.
Owen4652
Jul 30 2025, 03:23

Sui's RPC differs from Ethereum's by being object-centric, supporting parallel execution, and using Move's type system. Ethereum relies on account-based state and EVM execution, while Sui exposes objects with unique IDs, ownership, and structured data. Sui uses Programmable Transaction Blocks (PTBs) for multi-step transactions, enables rich queries (e.g., by object or sender), and emits typed events via sui_getEvents. Use sui_getObject and sui_getDynamicFields to inspect state, and always validate object ownership in Move code. Avoid ObjectNotFound errors by refreshing object references. Prefer PTBs via the Sui SDK, and never trust client-provided IDs without validation.

6
Comments
.
Evgeniy CRYPTOCOIN.
Jul 30 2025, 08:33

Sui natively supports parallel transaction processing via its object model. To handle concurrency safely:

1. Use Object Wrapping/Ownership

  • Exclusive Access: If an object is mutable, Sui ensures only one transaction can modify it at a time (via ownership).
  • Shared Access: For read-heavy objects, use immutable references or shared objects (no runtime locks needed).

2. Leverage Sui’s Object Types

  • Owned Objects: Safe for writes (Sui serializes access automatically).
  • Shared Objects: Use sui::transfer::share for multi-writer scenarios (e.g., auctions, games).

3. Avoid Conflicts

Split Data: Divide hot objects into smaller chunks (e.g., per-user sub-objects).
Atomic Batch: Use programmable transactions (PTBs) for multi-object ops.

Example:

// Shared object (concurrent-safe)  
shared struct GameState { players: vector<address>, ... }  

Key Benefit: No manual locking—Sui’s runtime handles parallelism.

Watch For: Overusing shared objects (higher gas costs).

4
Comments
.
BigSneh.
Jul 28 2025, 02:38

In Sui, concurrency is managed through its object-centric data model, which ensures that transactions accessing independent objects can execute in parallel without conflict. However, when multiple users interact with the same object, Sui enforces strict ownership and locking rules that prevent concurrent mutations to avoid race conditions.

Here are key practices to handle concurrency effectively:

  1. Use shared objects for coordination: If multiple users need to interact with the same resource, design it as a shared object, which allows parallel reads and controlled writes via Move entry functions.

  2. Minimize mutable access: Design modules so that most operations require only immutable access. Mutable references to objects create execution bottlenecks.

  3. Avoid hot object bottlenecks: Break down large or frequently-accessed objects into smaller components, so not every transaction needs the same object.

  4. Design with fine-grained state partitioning: Use individual objects per user/session to avoid locking the same object for all users.

  5. Use events and subscriptions to coordinate off-chain logic rather than relying on synchronous state changes in shared objects.

  6. Batch transactions where possible, so you reduce the number of interactions with a shared object.

  7. Apply optimistic updates off-chain, and let failed transactions roll back without affecting the UX.

  8. Gracefully handle failures, since concurrent writes will often result in transaction aborts if they collide.

By designing your dApp to minimize shared mutable state and using shared objects wisely, you can take full advantage of Sui’s parallel execution and reduce transaction conflicts.

3
Comments
.
SuiLover.
Jul 28 2025, 02:40

in Sui, concurrent transactions are governed by its object-based execution model. Each object has a unique ID, version, and owner, and transactions can only mutate an object if they have mutable access. When multiple users interact with the same object, Sui uses versioned locking to ensure only one transaction can mutate that object at a time. If two transactions try to modify the same object simultaneously, only one will succeed, and the other will fail due to an object version mismatch. This mechanism prevents race conditions but introduces the challenge of avoiding contention.

To handle concurrency effectively, design your dApp to reduce reliance on shared mutable objects. Instead of having all users interact with one central object, split data into multiple objects tied to individual users. This approach leverages Sui’s parallel execution engine, allowing more transactions to run concurrently without conflict. For example, store user balances in separate vault objects rather than a single shared pool. When shared state is unavoidable, convert it into a shared object and manage access using Move functions with controlled entry points.

Use fine-grained access control in your Move modules to limit when and how shared objects are mutated. You can also design entry functions to do more computation with fewer mutable operations, reducing lock contention. If you need to read shared object state, ensure that the function only requires immutable access. Consider emitting events from your Move modules to track shared state changes off-chain without requiring direct object access. Use optimistic UI updates in the frontend, assuming success, and handle failure scenarios by checking transaction results and retrying if necessary.

Batching transactions carefully can also reduce the number of interactions required with a shared object. Always monitor your system to detect hot objects, which are objects that receive frequent access and may cause bottlenecks. You can redesign those hotspots to spread load across more granular objects. On the backend, queue transactions or serialize conflicting operations where feasible. Logging and metrics will help identify which objects are causing transaction failures due to version conflicts.

Finally, write retry logic on your client or server to gracefully handle object lock errors. Structuring your data model with concurrency in mind ensures that your dApp scales under load and provides a smooth experience for users. Sui’s architecture rewards developers who understand object dependencies and optimize for parallelism.

2
Comments
.
Matthardy.
Aug 15 2025, 13:30

Sui uses a unique approach with parallel execution and Move-based transactions. Each transaction operates on independent objects or locked groups of objects, allowing concurrency without conflicts. To avoid issues:

Object-level locking: Sui locks objects during a transaction to prevent race conditions. Transaction grouping: Transactions that operate on the same object can be grouped, ensuring they are processed in order. Optimistic concurrency: Sui assumes that most transactions will succeed, only verifying conflicts during commit. By designing your dApp with proper object isolation and transaction ordering, you can minimize conflicts and maximize parallelism.

2
Comments
.
Paul.
Paul4300
Jul 31 2025, 10:00

In Sui, handling concurrent transactions—especially when multiple users are interacting with the same object—relies heavily on Sui’s object-centric transaction model and the ownership system of objects. Sui employs a unique asynchronous and parallel execution approach that helps handle concurrency without requiring traditional locking mechanisms, as you would find in more centralized systems or some other blockchain architectures.

Here’s how Sui handles concurrency and how you can design your dApp to avoid conflicts:

1. Object Ownership and Transactions

  • Object-based model: In Sui, everything is an object, and each object has a single owner. The owner of an object can be an account or another object.
  • Ownership defines transaction access: Only the owner of an object can modify that object. This is central to how Sui handles concurrency because it prevents conflicts from arising when two transactions attempt to modify the same object at the same time.
  • Locking mechanism: Since each object has a single owner, transactions on objects are atomic, meaning that a transaction can only access and modify an object when it holds the lock on that object (i.e., it owns it).

Example: If two users try to modify the same NFT (an object) in the same transaction block, only the user who owns that NFT can successfully perform the transaction. The other transaction will fail with an error indicating that the object is already locked.

2. Sui’s Concurrency Control:

  • Object locks: For concurrency control, Sui uses the concept of object locks. These locks are granted to the owner of an object during a transaction, and no other transaction can modify that object until the lock is released (i.e., the transaction is complete).
  • Independent objects: Sui’s parallel transaction execution model means that transactions that modify independent objects can run in parallel. However, if two transactions attempt to modify the same object or dependent objects, the one that gets to hold the lock will proceed, and the other will fail.

3. Conflict Handling

  • Transaction Conflicts: If two transactions attempt to modify the same object simultaneously, one will succeed while the other will be rejected. Sui handles this conflict automatically. The failed transaction will return an error indicating that the object is already locked by another transaction.

  • Re-try Logic: In your dApp, you should implement a retry mechanism to handle the case where a transaction fails due to concurrency. This can involve:

    • Polling the state: After a failure, you can check the current state of the object and retry the transaction after a short delay.
    • User feedback: Inform users when their transaction fails due to concurrency and ask them to try again or notify them of the success of their transaction.

4. Best Practices to Avoid Conflicts

  • Object Ownership Design: Structure your objects such that conflicting access is minimized. For example:

    • Splitting objects: Instead of having a single object that many users modify, split the object into multiple smaller objects, each owned by different users or groups. This allows parallel transactions to happen without conflict.
    • Batching operations: Group operations on related objects into a single transaction whenever possible to avoid concurrency issues between transactions.
  • Concurrency Aware Smart Contracts: If you're writing Move contracts, make sure they are idempotent (i.e., they can be repeated without changing the outcome if there’s a retry), which makes them more robust when concurrency issues arise.

  • Event Subscription: You can listen to specific events and use them to inform your dApp when an object has been updated. This can help your dApp make smarter decisions about when to retry a transaction.

5. Sui's Event System for Concurrency Management

  • Event Subscription: Sui allows you to subscribe to events on objects. For example, you can subscribe to events like “object changed” or “transaction completed.” Using these events, you can track the state of an object and ensure that your dApp responds to any changes in the object’s state, helping to avoid conflicts and retries in real-time.

6. Example Code for Handling Concurrency in a Move Smart Contract

Here’s a simple conceptual example of how you might handle ownership and modify an object in Sui using the Move language:

address 0x1234 {
    module ConcurrencyExample {
        use 0x2::Object;

        public fun modify_object(owner: address, obj: &mut Object): bool {
            if (Object::owner(obj) != owner) {
                // If the caller is not the owner, they cannot modify the object
                return false;
            }

            // Modify the object safely here
            // Example: Update some internal state of the object

            return true;
        }
    }
}

In this contract, only the owner of an object can modify it. This logic prevents two users from modifying the same object at the same time, ensuring safe concurrency.

7. Concurrency Strategies for Your dApp

  • Optimistic Updates: In scenarios where you can predict the outcome, you can allow users to interact with the object even before the transaction has been confirmed, and then roll back the change if the transaction fails.
  • Polling and Delay: Poll the object state and try again if a transaction fails. Ensure that you handle the retries in the UI with user-friendly messaging.
  • User Notifications: Provide feedback to the users, especially in case of failures due to concurrency issues. This feedback loop can help guide the user experience in a more seamless manner.

Example Using Sui CLI for Concurrent Transaction Handling:

Let’s say you want to deploy a contract that handles an NFT system, and multiple users will be interacting with the same NFTs. You’d use the following CLI commands to manage the deployment and transaction flow:

  1. Deploy Move Package:

    sui move deploy --network testnet --package ./my_nft_package --sender 0x1234
    
  2. Send Transaction:

    sui transaction --network testnet --sender 0x1234 --transaction <transaction_data>
    
  3. Transaction Failure Handling: You can add retry logic in your app that waits for the event of a transaction being successfully included:

    sui event listen --network testnet --object <object_id>
    

    Use this to track changes to the object’s state and decide whether to retry or proceed.

8. Security Considerations

  • Correct Access Control: Ensure that the proper access controls are in place, and always verify ownership before performing any modification.
  • Rate Limiting and Backpressure: Implement mechanisms to limit the number of transactions per user or per object to avoid spam and abuse.
  • Transaction Finality: Since Sui has parallel execution, ensure that transactions are finalized correctly before making critical decisions (like transferring assets or changing permissions).

Conclusion

Sui handles concurrency through a single-owner model for objects, where only the object owner can modify the object. This greatly simplifies concurrency management compared to other blockchains that require more complex locking mechanisms or transaction queues. To avoid conflicts, design your object access patterns carefully, implement retry mechanisms, and leverage Sui’s event system to keep track of object states.

By following these best practices, you can ensure your dApp behaves predictably, even under high concurrency conditions, and avoids common pitfalls when working with multiple users interacting with the same object.

0
Comments
.

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.

1166Posts3581Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignAugust