Transfer ownership of NFT to buyer in exchange for ether

The scenario is that the contract has been deployed to the blockchain and the NFT is minted. Two questions:

  1. how do you implement in solidity the ability to give ownership of the NFT to the buyer in exchange for a specific amount of ether going from seller to buyer?
  2. do I need to write a separate contract for this to happen or can I include all functionality in the original smart contract?

Thank you for taking the time to reply! Links to guides that answer my questions are also appreciated. :slight_smile:

1 Like

Hi @m3nt0r,

I would look at existing marketplaces which likely have a wide audience to see if this was suitable for your use case e.g. OpenSea, rather than creating your own sale contract.

You would need to create an exchange/sale contract. You could look at the OpenZeppelin Contracts Crowdsale contracts for some ideas: https://docs.openzeppelin.com/contracts/4.x/crowdsales

Your sale contract would need to hold the token (or be granted an allowance), assuming that the tokens have already been minted.

I recommend only including functionality required for the life of the contract. When selling tokens, if the sale has a limited life, then I would make this separate from the token. This separates the concerns.

1 Like