Is there a relevant difference for an ER721 contract? Is there a difference in gas cost?
2 Answers
I am familiar to which implementations you are referring. (As this is not a specified ERC-721 feature.)
The _safeMint flavor of minting causes the recipient of the tokens, if it is a smart contract, to react upon receipt of the tokens.
Here is a general consideration to help you decide which one to use:
- If YOU are paying for the minting of tokens, use
_mint. The_safeMintmight cost you an arbitrary amount of money because of choices made by the recipient of the tokens. This is enough to deter you from considering it. - If THEY are paying for the minting of tokens and you expect buyers to be composing functionality with smart contracts, use
_safeMint. There is some marginal benefit of allowing the extra features with smart contracts this allows. - If THEY are paying and you expect INDIVIDUAL PEOPLE to buy tokens, then use
_mint. The extra features in_safeMintare not expected.
The extra cost from using _safeMint is non-zero. And cost is also always a concern.
- 4,690
- 15
- 42
_mint and _safeMint are not part of the ERC721 standard, so you should check the specific implementation of those methods to see what are the differences in the smart contract. Even differences in gas costs can only be verified looking at the code (plus sometimes the current state of the chain) and cannot be derived only by the interface.
This is always true for every smart contract, not only for those exposing a standard interface.
Please note also that, like other ERC token standards (i.e. ERC20), the specification is useful only to share the signature of the methods (name and parameters) to be able to interoperate with other smart contracts and application, but it does not impose a specific implementation nor it allow you to check if the smart contract behaves as you expected under the hood. Again, you must always check the code by your own.
- 5,487
- 17
- 25
YOUandTHEYare and whether you're talking about paying for the gas fee or paying for mint of the token (payable). – Ayrton Senna Mar 04 '22 at 13:14