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
1 Answer
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)
- On mint:
You just add a require statement under your
minting
function. ie:
function mint() public {
require(msg.value > [SOME_PRICE_IN_WEI]);
.
.
.
On "resell" You could also force the
transfer
andtransferFrom
functions to have this same require statement.On a UI like Opensea Most UIs like Opensea have the functionality to set a price of an NFT.
Hope it helps.
-
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 Commented Sep 12, 2021 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. Commented Sep 12, 2021 at 20:08
-
Thank you, can you find similar examples of working with the interface ? Commented Sep 13, 2021 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? Commented Sep 13, 2021 at 6:27
-