0

I have a question related to billing for NFT, is it possible to prescribe in the smart contract function to set the price ? The problem is that after posting the nft you need to press Salle, set the price, I would like to automate this

0

It depends on when you want to set the price. You can use msg.value to make sure they send you ETH (or whatever your native smart contract token is)

  1. On mint: You just add a require statement under your minting function. ie:
function mint() public {
  require(msg.value > [SOME_PRICE_IN_WEI]);
.
.
.
  1. On "resell" You could also force the transfer and transferFrom functions to have this same require statement.

  2. On a UI like Opensea Most UIs like Opensea have the functionality to set a price of an NFT.

Hope it helps.

5
  • Thanks for the reply. I don't quite understand the principle of price setting, I tried to create a function like function allowBuy(uint256 _tokenId, uint256 _price) external { require(msg.sender == ownerOf(_tokenId), 'Not owner of this token'); require(_price > 0, 'Price zero';) tokenIdToPrice[_tokenId] = _price; } But when I go to OpenSea I don't see the price, only the sell button Sep 12 at 4:41
  • Opensea has their own front end (website) that they put on top of smart contracts. If you wanted to see your functions, you'd have to build your own front end to do that. Sep 12 at 20:08
  • Thank you, can you find similar examples of working with the interface ? Sep 13 at 3:19
  • Awww, I'm sorry, I may have misunderstood. Do you mean that the price in the NFT can only be set through the OpenSea website or by writing your own web implementation? Sep 13 at 6:27
  • Pretty much, yes. Sep 13 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.