I have an ERC721 contract that has a whitelistEnabled
property which, if enabled, requires the user to pass a merkleproof
to the minting function. Currently, I have two functions: mint() {...}
and mintWhitelist(merkleproof) {...}
. Both functions have the same logic and custom implementation. The only difference is that the latter checks the merkleproof and the former doesn't.
Since the bulk of the two functions is the same, I was wondering if 'duplicating' the functions like this is the right, most gas efficient approach.
Would it be better to merge them into one? I think this might be the case, but I don't think there is a way to pass the merkleproof optionally (since there are no optional function parameters in Solidity).
Any help is appreciated!