Skip to content

Instantly share code, notes, and snippets.

@arcticfloyd1984
Last active March 14, 2022 17:39
Show Gist options
  • Save arcticfloyd1984/8e46ac89c1dd774a174c2406d1431586 to your computer and use it in GitHub Desktop.
Save arcticfloyd1984/8e46ac89c1dd774a174c2406d1431586 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
// import "@opengsn/gsn/contracts/BaseRelayRecipient.sol";
// import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/metatx/ERC2771Context.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/metatx/ERC2771Context.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/access/Ownable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/Strings.sol";
contract TravelGasless is ERC2771Context, ERC1155, Ownable { //0xab0ce2237830ad713b3134e5307521f20e1c0ff6
uint256[] supplies = [50,50,50];
uint256[] minted = [0,0,0];
mapping(uint256 => mapping(address => bool)) public member;
constructor(address trustedForwarder)
ERC1155("https://ipfs.io/ipfs/QmZNkDgivjBkXBSG5zVjt3vk6KfTzzSBowCRRoqMvcNahp/{id}.json")
ERC2771Context(trustedForwarder)
{
}
// function setURI(string memory newuri) public onlyOwner {
// _setURI(newuri);
// }
function uri(uint256 _tokenId) override public view returns (string memory) {
require(_tokenId <= supplies.length-1,"NFT does not exist");
return string(
abi.encodePacked(
"https://ipfs.io/ipfs/QmZNkDgivjBkXBSG5zVjt3vk6KfTzzSBowCRRoqMvcNahp/",
Strings.toString(_tokenId),
".json"
)
);
}
function mint(uint256 _tokenId)
public
{
require(
!member[_tokenId][_msgSender()],
"You have already claim NFT"
);
require(_tokenId <= supplies.length-1,"NFT does not exist");
uint256 index = _tokenId;
require (minted[index] + 1 <= supplies[index], "All the NFT have been minted");
_mint(_msgSender(), _tokenId, 1, "");
// "" is data which is set empty
minted[index] += 1;
member[_tokenId][_msgSender()] = true;
}
function totalNftMinted(uint256 _tokenId) public view returns(uint256){
return minted[_tokenId];
}
function _msgSender() internal view override(Context, ERC2771Context) returns (address){
return ERC2771Context._msgSender();
}
function _msgData() internal view override(Context, ERC2771Context) returns (bytes calldata){
return ERC2771Context._msgData();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment