I am developing an NFT Marketplace where I am distributing free NFTs(out of 3 defined categories, Diamond,Gold,Silver). I have developed a dropsite smart contract for this distribution. The dropsite module will only be executed once like it will mint only 1000 NFTs then it will be closed.
After distribution, I want those NFTs to be usable on Marketplace contract. For this I want to send the ownerships of Distributed NFTs from Dropsite contract to Marketplace contract. SO that the user may send/transfer/sell those NFTs on marketplace.
How can I achieve this?
Here is my Dropsite minting Contract:
//SPDX-License-Identifier:MIT
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import "./ERC1155_Dropsite.sol";
contract Dropsite is ERC1155_Dropsite {
//NFT category
bytes data ="";
uint TotalNFTsMinted; //Total NFTs
uint numOfCopies; //A user can mint only 1 NFT
//Initial Minting
uint Diamond;
uint Gold;
uint Silver;
//owner-NFT-ID Mapping
mapping (address=>uint) dropsite_NFT_Owner;
//payments Mapping
mapping (address => uint) deposits;
modifier OnlyOwner {
require(_msgSender() == Owner, "Only NFT-ES Owner can Access");
_;
}
//Pausing and activating the contract
modifier contractIsNotPaused(){
require (IsPaused == false, "Dropsite is not Opened Yet." );
_;
}
bool public IsPaused = true;
address payable public Owner;
string private _name;
constructor (string memory name){
_name = name;
Owner = payable(msg.sender);
TotalNFTsMinted=0; //Total NFTs Minted
numOfCopies=1; //A user can mint only 1 NFT
Diamond=0;
Gold=0;
Silver=0;
}
function checkMintedCategoryWise() public view OnlyOwner returns(uint,uint,uint){
return (Diamond,Gold,Silver);
}
function checkTotalMinted() public view OnlyOwner returns(uint){
return TotalNFTsMinted;
}
function stopDropsite() public OnlyOwner{
require(IsPaused==false, "Dropsite is already Stopped");
IsPaused=true;
}
function openDropsite() public OnlyOwner {
require(IsPaused==true, "Dropsite is already Running");
IsPaused=false;
}
//To WithDraw All Ammount from Contract to Owners Address
function withDraw(address payable to) public payable OnlyOwner {
uint Balance = address(this).balance;
require(Balance > 0 wei, "Error! No Balance to withdraw");
to.transfer(Balance);
}
//To Check Contract Balance in Wei
function ContractBalance() public view OnlyOwner returns (uint){
return address(this).balance;
}
function random() internal view returns (uint) {
//Only Returns 0,1,2
uint randomnumber = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 3;
return randomnumber;
}
function updateConditions(uint nftId) internal contractIsNotPaused {
// if nftID is 0, and less than 51 so 50 MAX
if(nftId == 0 && Diamond < 50) {
data = "Diamond";
Diamond++;
// if nftID is 0 or 1 and Diamond is more than 150, it will go there
} else if(nftId <= 1 && Gold < 100) {
data = "Gold";
Gold++;
// if any of the above conditions are filled it will mint silver if enough silver available
} else if(nftId <= 2 && Silver <= 850) {
data="Silver";
Silver++;
}
else
revert("Some Error Occured");
}
//Random minting after Fiat Payments
function FiatrandomMint(address user_addr) OnlyOwner contractIsNotPaused public returns (uint,string memory) {
require(TotalNFTsMinted<1000, "Max Minting Limit reached");
uint nftId = random(); // we're assuming that random() returns only 0,1,2
updateConditions(nftId);
_mint(user_addr, nftId, numOfCopies, data);
TotalNFTsMinted++;
dropsite_NFT_Owner[user_addr]=nftId;
return (nftId,string(data));
}
function depositAmount(address payee,uint amountToDeposit) internal {
deposits[payee] += amountToDeposit;
}
//Random minting after Crypto Payments
function CryptoRandomMint(address user_addr) contractIsNotPaused public payable returns (uint,string memory) {
require(TotalNFTsMinted<1000, "Max Minting Limit reached");
require(msg.value == (25), "Balance must be 25 Matics");
uint nftId = random(); // we're assuming that random() returns only 0,1,2
updateConditions(nftId);
_mint(user_addr, nftId, numOfCopies, data);
depositAmount(_msgSender(), msg.value);
TotalNFTsMinted++;
dropsite_NFT_Owner[user_addr]=nftId;
return (nftId,string(data));
}
}