0

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?

1 Answer 1

1

This is up to the miners to decide. Miners decide in which order the transactions should be ordered inside a block - and even decide which transactions to include in a block.

Typically miners sort orders by the amount of gas rewards it provides for the miner and choose as many as they can fit in a block.

Therefore, in essence, the one who pays the highest gas price gets it first. But remember that this is not a rule and the results may vary.

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.