nft-marketplace icon indicating copy to clipboard operation
nft-marketplace copied to clipboard

it is possible to pay for ERC721 nft with existing ERC20 token

Open Nakinthorn opened this issue 3 years ago • 3 comments

I have created my own ERC20 token already (1 year ago).

Now i try to deploy the ERC721 token for NFT marketplace. After i deploy by the tutorial everything work well. i

But if i want to mint, buy, sell via my own ERC20 token

How i can do ?

change the contract on .sol or something else ?

pls help me or explain

thx :)

Nakinthorn avatar Jan 22 '22 10:01 Nakinthorn

Hey, @NakamuraTokio! I believe you would have to implement some token transfers logic inside the ERC721 contract, in a way it removes a given ERC20 token quantity in the msg.sender account when he mints the NFT. He would have to approve it first, of course. If you give me a few days I can try it myself, but feel free to try it too if you've got the idea.

Markkop avatar Jan 22 '22 15:01 Markkop

Hey, @NakamuraTokio! I believe you would have to implement some token transfers logic inside the ERC721 contract, in a way it removes a given ERC20 token quantity in the msg.sender account when he mints the NFT. He would have to approve it first, of course. If you give me a few days I can try it myself, but feel free to try it too if you've got the idea.

thank you for your reply. i try to find the solution a week already. T_T

btw, if you can figure out this. will be very grateful

Nakinthorn avatar Jan 22 '22 16:01 Nakinthorn

What's up, @NakamuraTokio. I hope you've found a solution already. However, in case you haven't, I've managed it to implement in my project. Feel free to check it out, it's on feat/use-custom-token branch. You can see the diff code on #2: https://github.com/Markkop/nft-marketplace/pull/2/files

We're basically using the ERC20 .approve method before calling the createMarketItem and createMarketSale functions and using .transferFrom inside them.

Let me know if need help understanding it!

Markkop avatar Jan 30 '22 19:01 Markkop