You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to set the NFT price on the NftMarketplace in my own ERC20 token and not in ETH. It was set as a challenge, but I couldn't find the answer anywhere and I can't seem to figure it out myself. Anyone who could help me with this?
function buyItem(addressnftAddress, uint256tokenId)
externalpayableisListed(nftAddress, tokenId)
nonReentrant
{
// Challenge - How would you refactor this contract to take:// 1. Abitrary tokens as payment? (HINT - Chainlink Price Feeds!)// 2. Be able to set prices in other currencies?// 3. Tweet me @PatrickAlphaC if you come up with a solution!
Listing memory listedItem = s_listings[nftAddress][tokenId];
if (msg.value< listedItem.price) {
revertPriceNotMet(nftAddress, tokenId, listedItem.price);
}
s_proceeds[listedItem.seller] +=msg.value;
// Could just send the money...// https://fravoll.github.io/solidity-patterns/pull_over_push.htmldelete (s_listings[nftAddress][tokenId]);
IERC721(nftAddress).safeTransferFrom(listedItem.seller, msg.sender, tokenId);
// IERC20(s_paymentToken).transferFrom(msg.sender, listedItem.seller, msg.value);emitItemBought(msg.sender, nftAddress, tokenId, listedItem.price);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I want to set the NFT price on the NftMarketplace in my own ERC20 token and not in ETH. It was set as a challenge, but I couldn't find the answer anywhere and I can't seem to figure it out myself. Anyone who could help me with this?
Beta Was this translation helpful? Give feedback.
All reactions