Create a fungible non-fungible token

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 )
    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.

1 Like

I am not sure, but do you mean ERC1155?

1 Like

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.

1 Like

Hi @sroope,

It sounds like you want to create fungible tokens (an ERC20 token) for each non-fungible token. So something like ERC1155 could work.

You could also have a contract that owns the NFT that mints ERC20 tokens to represent the shared ownership.

Thanks @abcoathup

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.

1 Like

Hi @sroope,

I created a simple ERC1155 example: Create an ERC1155

You could potentially use an ERC1155 for fractional ownership, (or multiple copies of the same item).

You could potentially have an ERC721 which the holder of the token is an ERC20 token contract and the ERC20 tokens represent fractional ownership.

I suggest doing some web searches to see how projects are doing fractional ownership.

You could also look through the EIPs to see if anyone has done recent work on this: