I'm trying to build a contract that creates a parity 1:1 in between a token (e.g. PunkToken) and an NFT collection (e.g. CryptoPunk).
The idea is to deploy both the token and the NFT collection contracts. Then deploy a vault that stores all the created NFTs. Users can then exchange in both directions PunkToken for CryptoPunk vice-versa at a fixed 1:1 parity.
'Require' asides, my idea was to do something like this:
// create two functions for doing the swap both ways
function tokenToNft() public payable {
_transfer(address(this), msg.sender, 1); // _transfer function from ERC721
}
function nftToToken() public payable {
_transfer(address(this), msg.sender, 1); // _transfer function from ERC20
}
To do so, I tried importing both ERC20 and ERC721 but quickly ran into clashes due to the identical functions names. I then tried to change the names of the ERC20 functions. Not working since the token became unrecognized by the blockchain (I believe).