0

I am working on an NFT collection of 10,000 images (1000 images per character). I want to allow users to pay a premium to mint a chosen character, and was thinking of storing a mapping of tokenIds to wallet addresses where IDs 0-1000 represent character 1, 1001-2000 represent character 2, etc. I was wondering how this/whether this works with concurrent transactions? Let's say two buyers want to buy character 2, so we start at key 1001 and look until we have an empty owner. Would it be possible for both buyers to end up with the same token ID?

1 Answer 1

0

I haven't notice any concurrency synchronization mechanism in solidity which should open the possibility for dirty data (e.g. variable is overriden by another thread) and ambiguity of the ownership (e.g. two users 'owns' the same id).

However there is such thing like consensus which would confirm a whole chain as common truth including a new block with your transaction.

Let's consider your case in theory. As there is two users where each of them performs the action on the chain, there would be two transactions and in case of ambiguity in data there would be two chains - a fork in the one origin chain. Nodes consensus would decide which branch to keep and which one discard. It should resolve ambiguity, but it leaves open issue with dirty data. Ethereum should resolves it too.

This is my current understanding. Let's see what others community members will share.

3
  • Transactions are processed in block order, so one transaction cannot overwrite another transaction state (unless the contract explicitly allows to do so).
    – Ismael
    Commented Oct 4, 2022 at 13:38
  • I'm keeping in mind the case when both transactions (e.g. txb1 and txb2) has made on top of the same transaction (txa). A one node executes the first tx (txb1), another node -- second tx (txb2). We will get a fork, 2 chains, and during consensus one would be kept and another one discarded. Is it not correct?
    – Gleichmut
    Commented Oct 4, 2022 at 14:03
  • Yes, something like that happens. The transactions will be ordered in some sequence txa -> txb1 -> txb2 or txa -> txb2 -> txb1.
    – Ismael
    Commented Oct 4, 2022 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.