NFT transfer amount for marketplace

Hi, I’m working on a small market site where people can upload a digital resource, set a price, and be able to sell the resource on the market, with the possibility of having royalties. The site will do almost everything (minting, sell, etc), the users will only need to upload the resource, set the price and the royalties %, and provide a eth address. I already have a code working, but only for mint. this is the code I have:

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol";

contract MyNFT is AccessControl, ERC721Burnable {
    using Counters for Counters.Counter;

    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    Counters.Counter private _tokenIdTracker;

    constructor () public ERC721("MyNFT", "PCT") {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(MINTER_ROLE, _msgSender());

    function mint(address to, uint256 tokenId) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "must have minter role to mint");

        _mint(to, tokenId);

    function getNumberOfMintedNFT() public view returns (uint256) {
        return _tokenIdTracker.current();

My next step is be able to set a price and had a transfer function. I was reading and I think I have to have a price for each minted token, and a function to change that price (if the user decide to change it). I will appreciate some help with this (code or steps on how to do this).
And if you also know hoe to implement the royalties will be great.

1 Like

Hi @carlosjct,

Welcome to the community :wave:

I suggest looking at existing marketplaces to see how they do this. e.g. do they have a marketplace contract, what types of sales/auctions do they allow, how they minimize the number and cost of transactions.

Alternatively, could you use an existing marketplace such as OpenSea and focus on the onboarding of people to create their NFTs?

I’m doing the research for another company, so using OpenSea is not an option. But thanks, I will looking how existing marketplaces are doing.

1 Like