NexaScript - how to handle concurrency?

Key Limitation: A Single UTXO Can Only Be Spent Once

  • A contract on Nexa is bound to a single UTXO. Once you spend it, that UTXO vanishes, replaced by new UTXOs.
  • Concurrency in the sense “User A and B both call the same UTXO at the same time” leads to a double-spend conflict.
    • Whichever transaction is confirmed first “wins”; the other becomes invalid.

Hence, you cannot have multiple separate transactions simultaneously updating the same “internal” variable from the same UTXO.
What are the ways to handle multiple users concurrent interactions with a contract like an account based chain (EVM) ? if sharing in multiple UTXO : how to shard and handle the logic on a common variable ?

2 Likes

Contracts are different on Nexa than on EVM. Each “contract” have a new “contract address”, so they don’t have a single state or address like on EVM. Advantage of that Nexa can work in parallel, and handle way more transactions, that’s how we achieve scalability with decentralization.

1 Like

A contract is not necessarily bound to a single utxo. A contract can also be an address and applied to all utxos that address owns or it can be a series of utxos controlled by many addresses. it depends on how the contract is written.

It is possible to store contract state, or as you put it “sn internal variable” but there is no way to have multiple transactions simultaneously update the same internal variable. contracts that use an single internal state variable can not have concurrency on nexa. parallel processing of utxo transactions will create a race condition and the internal variable will break.

you have to process the transactions sequentially the same way EVM does.

1 Like