I was learning to create NFT markertplace (openZeppelin-ERC721) and got stuck in counter. I wander what happen when this code below is executed.
pragma solidity ^0.8.0;
library Counters {
struct Counter { uint256 _value; }
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked { counter._value += 1; }
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked { counter._value = value - 1; }
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
Suppose person A and B both are trying to create NFT and the counter is supposed to increment and give them ID for their NFTs. But, what if they both try to create NFT at the same time, I mean ofcourse there is a lot of chance of happening this. Will the other NFT will be discarded, get a new ID and if so, wouldn't it take a bit longer than expected? what about the GAS fees then???
Lots of question I hope you understand what I am trying to say!