Best practice for transforming multiple tokens of an erc721 into new one

Hi everyone,

I'm currently working on an ERC721 that has following business requirements:

I want to define specific tokens that are able to been minted by users if they own and put in a set of other combination of tokens with defined categories.

Means for instance if a user owns tokens of the category type

3x A + 2x B , the user has the ability to burn these for getting one precreated token of type C.

Means I define dynamically several sets of type C and define that users are able to get them if they put in and burn A+A+A+B+B.

There is then a limit set of Cs. Only these, that I've created. And I can create new combinations later (eg. 1xC + 4xA + 2xB to get a D), or even also additional C's.

How would you suggest to do this?
From outside: A website with webservice as Oracle, that creates type C if user transfers his As and Bs?

Or directly as a method in the smart contract.
If I do this in the smart contract, are there examples out there?

Thanks in advance.

I would recommend doing this in the smart contract. I haven't seen examples though.

If all of this is going to be part of the same system, it looks like ERC1155 would be a really good fit, as you can represent all of A, B, and C in the same contract.

You should also be able to do it with ERC721 though. As a starting point, I think the function should be something like:

functiont mintC(uint[] a, uint[] b) public {
    require(a.length == 3 && b.length == 2);
    aToken.transferFrom(msg.sender, this, a[0]);
    bToken.transferFrom(msg.sender, this, b[0]);
    _mint(msg.sender, ...);