Imagine a smart contract that is able to mint NFTs that represent natural numbers: 0
, 1
, 2
, ... simply by their token id.
The function to mint a new NFT is accessible for everybody and attributes the minted NFT to the sender of the transaction:
function safeMint(uint256 naturalNumber) public {
require(_exists(naturalNumber) == false, "This natural number was already minted");
_safeMint(msg.sender(), naturalNumber);
}
For example, this means that the first one to call the safeMint(3)
function will be the first owner of the NFT representing the natural number 3
. If somebody else tries to mint 3
again, the transaction will be reverted.
If two addresses try to mint the number 3
in two different blocks, the NFT will of course be attributed to the address that minted the NFT in the first block.
However, it is possible that two addresses try to mint the number 3
in the same block. If this is the case, how will ethereum decide which transaction to perform first as this will effectively define who will be the owner of the NFT. Can we consider that the transaction that proposes to pay the highest gas price will be executed first?
Would this logic change on the Polygon PoS chain?