matic-docs icon indicating copy to clipboard operation
matic-docs copied to clipboard

Polygon Mintable Assets: explain why mint function is required in child contract (actually, it shouldn't be)

Open php4fan opened this issue 3 years ago • 1 comments

NOTE: I'm concerned about ERC721 tokens. What I say may or may not apply to other types of tokens such as ERC20 or ERC1155.

Here: https://docs.polygon.technology/docs/develop/ethereum-polygon/mintable-assets/#contract-to-be-deployed-on-polygon-chain

you say:

but ensure that the deposit, withdraw and mint functions are present.

Why should you care whether or not the mint function is present? How the tokens are minted shouldn't be any of your business.

Normally, when creating a ERC721 contract, the decision of what external function has the effect of minting a token, under what conditions, how it's called, what arguments it accepts etc., is up to me.

I may have a super-complex contract with which users interact in a super-complex way and as a result of those intricated interactions at some point under certain conditions a token is minted and assigned to an owner. The ERC721 standard has nothing to say about all of that, as long as, once a token is minted, it obeys the rules of the ERC721 standard, that is, it has an owner, it can be transferred, etc. And I don't see how the bridge protocol should care either (as long as certain conditions are satisfied such as never minting a token that has already been withdrawn).

In your example child contract you have a function:

function mint(address user, uint256 tokenId) public only(DEFAULT_ADMIN_ROLE) {
...

but that is just an example, as you say yourself. That does not cover the most general use case. The greatest limitation of this example is that the mint function might require more arguments. Or less. And at that point, there is no point in requiring that it exists with a given name.

In my use case scenario, the minting function (meaning the function that people call, which results in minting a token) is not designed to be called by the contract owner/administrator, but by anybody. People who the function, pass it certain parameters that include, among other things, a message signed by me, which the contract verifies. So, anybody can mint a token (and be its initial owner) on my contract as long as they have previously obtained a token id and a "code" that match. The function that they need to call (which results in minting a token if all the arguments are valid) requires several arguments. I can call it mint(), but I cannot make it have the signature above.

I could satisfy the requirement by having a mint() function with the required signature that actually does nothing, and the true work is done by another function that I design as I wish (complying with all the other requirements), but then what's the point of the requirement??

If there is something that I am missing, it definitely needs to be explained in the docs, because you say that the mint() function must be present, and that raises all these question, and none of them is addressed.

php4fan avatar Apr 23 '22 17:04 php4fan

Hi @php4fan, we appreciate the feedback. We will look into the intent to present mint() this way and provide context/update shortly

salmad3 avatar Apr 25 '22 19:04 salmad3