solidity – How to Access the Sale Price of an NFT Asset in Your NFT Contract

erc-721nftopenseapayablesolidity

I have a unique case in which I want to implement an NFT contract that prevents users from selling/transferring NFT tokens below a specific ether price. Opensea uses wyvern protocol for NFT order matching (atomicMatch). According to my understanding the current NFT token trade flow (simplified) on opensea is as follows

Seller
Seller clicks sell for the first time on opensea
SetApprovalForAll triggers allowing the operator (proxy account) to operate on all of his tokens.
Seller list an nft for sale by sending Signed message that approves operator to transfer that specific nft on owners' behalf when properly matched with buy order.

Buyer
Buyer clicks buy on listed NFT -> AtomicMatch Triggers.
AtomicMatch()
Verifies already signed order and Match both buy and sell orders.
executeFundsTransfer(buy, sell); Transfer funds and fees. returns price for which asset is being sold/bought for.
call or delegatecall safeTransferFrom() of nft contract to transfer asset

Now I only have control over the very last step safeTransferFrom() how can I know in that function that how much ether value/price the asset is being sold for and obviously then I can prevent it from being sold under a specific price

The whole process is one single transaction so I believe there should be some way to access the data of executeFundsTransfer() or any workaround for this problem.

Best Answer

The order matching information -- buy order, sell order -- is not saved or accessible on chain in a way that your contract can be read during transfers.

There is some way to do what you are saying, but it is not necessarily what you want.

You can disable all ERC-721 transfers in your contract unless they are initiated by your contract itself. So you create your own match order function to evaluate the atomic order and only put the order through if you like it.

This means people cannot buy/sell on OpenSea directly, but they can take those orders and execute on your website.

Related Topic