Is it possible to create a contract extended by ERC721 & ERC20? I tried, but there are clashes between the shared function names of the two token types e.g. _mint & _transfer. Both these functions would be required in the functionality of the contract, so I don’t think it is a case of overriding the functions. Can an alias be assigned to each of the underlying functions?
For example:
pragma solidity ^0.6.12;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract Token is ERC721, ERC20 {
address public factoryAddress;
constructor( string memory name, string memory symbol, address _to, uint _tokenId, uint _amount )
public
ERC721( name, symbol )
ERC20 ( name, symbol )
{
_mint ( _to, _amount ); // Mint ERC20
_mint ( _to, _tokenId ); // Mint ERC721
}
}
This example doesn’t compile, with the error ‘two or more base classes define functions with the same name and parameter types’ thrown for finctions _mint, _transfer, name, symbol, balanceOf. If it did compile, there is still no way to distinguish between the two _mint functions.
The ERC1155 standard allows for the creation of either an ERC20 or ERC721 token. My need is for a hierarchy; an ERC721 token that also has the split ownership characteristics of an ERC20 token.
The scenario is: an art dealer buys paintings but instead of selling to a single person, ownership of the painting is split and shares sold to many investors. The addresses are the dealers, paintings (NFT + FT) and investors. Could you expand on your suggestion of using ERC1155 and a steer towards the code required to create a contract that owns the NFT that mints ERC20 tokens? I’m finding the understanding of the ERC concepts the most challenging. Many thanks.