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") {
_setBaseURI("https://example.com/tokens/");
_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);
_tokenIdTracker.increment();
}
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.
Thanks.