I am creating a Dapp for ERC721 NFTs. To execute a sale of an NFT from one user to another on my smart contract, I am calling the
_safeTransfer function of openzeppelin from within another external function (called from my front-end). In exchange of the NFT, Ethers will need to be transferred from the purchaser to the seller using
seller.transfer(msg.value). Furthermore, a commission will need to be sent to the smart contract itself.
My question is, how should I execute these three transactions (
seller.transfer(msg.value) and send Ether to the contract) on my smart contract? From my understanding, if I initiate a "send" call from my Dapp, all the funds would go to the smart contract? Is this correct? If this is correct, I assume that I should be sending the funds to the seller from the smart contract after executing the _safeTransfer function? Is this how it is typically done?
Also, how can I revert ALL the transactions if the NFT or Ether transfer to the seller fails?
Thank you. J