Does anyone knows how to get a fee from NFT minters?
I’m creating NFT marketplace. Every user can mint their NFTs. This part is ok. It’s working with below code.
But I have no idea how can I get a fee.
For example, I will get 1 MATIC when user mint their token.
Maybe I need to send 1 MATIC to owner’s address. Ideally I wanna pop up the 1 MATIC message on Metamask before user minting.
How can I do that?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract NFTCryplo is ERC1155, Ownable {
mapping(uint256 => address) private minters;
constructor() ERC1155(""){}
function mint(address account,uint256 id,uint256 amount) public {
require(minters[id] == address(0) || minters[id] == msg.sender);
if(minters[id] == address(0)) {
minters[id] = msg.sender;
}
_mint(account,id,amount,"");
}
function uri(uint256 _id) override public pure returns (string memory) {
return string(
abi.encodePacked(
"https://my-server-returns-json.com/nft/metadatas/",
Strings.toString(_id)
)
);
}
}