-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f70289
commit 94af202
Showing
4 changed files
with
205 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
|
||
import "@openzeppelin/contracts/utils/Address.sol"; | ||
import "@openzeppelin/contracts/utils/Counters.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; | ||
|
||
// | ||
// ______ _______ ____ ____ _______ ____ ____ | ||
// .' ___ ||_ __ \ |_ _||_ _| |_ __ \|_ || _| | ||
// / .' \_| | |__) | \ \ / / | |__) | | |__| | | ||
// | | ____ | __ / \ \/ / | ___/ | __ | | ||
// \ `.___] |_| | \ \_ _| |_ _ _| |_ _| | | |_ | ||
// `._____.'|____| |___||______|(_)|_____| |____||____| | ||
// | ||
// CROSS CHAIN NFT MARKETPLACE | ||
// https://www.gry.ph/ | ||
// | ||
|
||
// ============ Errors ============ | ||
|
||
error InvalidName(); | ||
error InvalidAmountSent(); | ||
|
||
contract GryphNamespaces is ERC721, Ownable, ReentrancyGuard { | ||
using Counters for Counters.Counter; | ||
// ============ Constants ============ | ||
|
||
uint256[] public PRICES = [ | ||
0.192 ether, //4 letters | ||
0.096 ether, //5 letters | ||
0.048 ether, //6 letters | ||
0.024 ether, //7 letters | ||
0.012 ether, //8 letters | ||
0.006 ether, //9 letters | ||
0.003 ether //10 letters or more | ||
]; | ||
|
||
// ============ Storage ============ | ||
|
||
Counters.Counter private _tokenIdTracker; | ||
|
||
//mapping of token id to name | ||
mapping(uint256 => string) public tokenName; | ||
|
||
//mapping of name to token id | ||
mapping(string => uint256) public reserved; | ||
|
||
//mapping of names to blacklist | ||
mapping(string => bool) public blacklisted; | ||
|
||
// ============ Deploy ============ | ||
|
||
/** | ||
* @dev Sets the erc721 required fields | ||
*/ | ||
constructor() ERC721("Gryph Namespaces", "GNS") {} | ||
|
||
// ============ Write Methods ============ | ||
|
||
/** | ||
* @dev Allows anyone to buy a name | ||
*/ | ||
function buy(address recipient, string memory name) external payable { | ||
//get the length of name | ||
uint256 length = bytes(name).length; | ||
//disallow length length less than 4 | ||
if (length < 4) revert InvalidName(); | ||
//get index | ||
uint256 index = length - 4; | ||
if (index >= PRICES.length) { | ||
index = PRICES.length - 1; | ||
} | ||
//check price | ||
if (msg.value < PRICES[index]) revert InvalidAmountSent(); | ||
//okay to mint | ||
_nameMint(recipient, name); | ||
} | ||
|
||
// ============ Admin Methods ============ | ||
|
||
/** | ||
* @dev Disallows `names` | ||
*/ | ||
function blacklist(string[] memory names) public onlyOwner { | ||
for (uint256 i = 0; i < names.length; i++) { | ||
//we can't blacklist if the name is already reserved | ||
if (reserved[names[i]] > 0) revert InvalidName(); | ||
blacklisted[names[i]] = true; | ||
} | ||
} | ||
|
||
/** | ||
* @dev Allow admin to mint a name without paying (used for airdrops) | ||
*/ | ||
function mint(address recipient, string memory name) public onlyOwner { | ||
_nameMint(recipient, name); | ||
} | ||
|
||
/** | ||
* @dev Allow `names` | ||
*/ | ||
function whitelist(string[] memory names) public onlyOwner { | ||
for (uint256 i = 0; i < names.length; i++) { | ||
blacklisted[names[i]] = false; | ||
} | ||
} | ||
|
||
/** | ||
* @dev Sends the entire contract balance to a `recipient` | ||
*/ | ||
function withdraw(address recipient) | ||
external virtual nonReentrant onlyOwner | ||
{ | ||
Address.sendValue(payable(recipient), address(this).balance); | ||
} | ||
|
||
/** | ||
* @dev This contract should not hold any tokens in the first place. | ||
* This method exists to transfer out tokens funds. | ||
*/ | ||
function withdraw(IERC20 erc20, address recipient, uint256 amount) | ||
external virtual nonReentrant onlyOwner | ||
{ | ||
SafeERC20.safeTransfer(erc20, recipient, amount); | ||
} | ||
|
||
// ============ Internal Methods ============ | ||
|
||
function _nameMint(address recipient, string memory name) internal { | ||
//already reserved or blacklisted | ||
if (reserved[name] > 0 || blacklisted[name]) revert InvalidName(); | ||
// We cannot just use balanceOf to create the new tokenId because tokens | ||
// can be burned (destroyed), so we need a separate counter. | ||
// first increment | ||
_tokenIdTracker.increment(); | ||
//get token id | ||
uint256 tokenId = _tokenIdTracker.current(); | ||
//now mint | ||
_safeMint(recipient, tokenId); | ||
//now add name | ||
tokenName[tokenId] = name; | ||
reserved[name] = tokenId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[ | ||
"arvr", | ||
"atom", | ||
"avax", | ||
"doge", | ||
"bttc", | ||
"busd", | ||
"dash", | ||
"fake", | ||
"flow", | ||
"game", | ||
"help", | ||
"land", | ||
"link", | ||
"luna", | ||
"meta", | ||
"near", | ||
"play", | ||
"sale", | ||
"scam", | ||
"shib", | ||
"shop", | ||
"swap", | ||
"tron", | ||
"tusd", | ||
"usdt", | ||
"usdc", | ||
"about", | ||
"chain", | ||
"games", | ||
"gryph", | ||
"matic", | ||
"music", | ||
"sales", | ||
"bitcoin", | ||
"sports", | ||
"fashion", | ||
"polygon", | ||
"presale", | ||
"roadmap", | ||
"support", | ||
"business", | ||
"ethereum", | ||
"exchange", | ||
"explorer", | ||
"phishing", | ||
"community", | ||
"sidechain", | ||
"whitelist", | ||
"whitepaper", | ||
"marketplace" | ||
] |