Skip to content

Commit

Permalink
gryph namespace for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
cblanquera committed Mar 7, 2022
1 parent 1f70289 commit 94af202
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 24 deletions.
24 changes: 1 addition & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
# GRY.PH NFT Smart Contracts

The contract defined here are to allow auditors to evaluate the contracts that
are designed and specifically for the purpose of the GRY.PH project. It
specifies the process of digitizing collectable designs. Some of the business
requirements include the following.

- Ability to cheaply define a set of tokens that can be minted for each design which include the following.
- Design information
- Token quantity limits
- Royalty Fees
- Ability to mint tokens cheaply or,
- Ability to facilitate air drops off chain and,
- Ability for buyers to redeem air drops and pay the minting costs.
- Ability for holders to list tokens in a decentralized manner and,
- Ability for buyers to purchase listed tokens on any NFT marketplace while having,
- Ability to distribute royalties no matter where it was exchanged

# Considerations

- Use ERC1155 instead of ERC721
- Use Enjin or Polygon instead of Ethereum
- Rarible Compatibility

#### Compatibility

Solidity ^0.8.0

- Recommended v0.8.4
- Recommended v0.8.9

## 1. Install

Expand Down
151 changes: 151 additions & 0 deletions contracts/GryphNamespaces.sol
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;
}
}
2 changes: 1 addition & 1 deletion contracts/GryphVesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract GryphVesting is
AccessControlEnumerable,
ReentrancyGuard
{
//so we can invoke mint function in vest and invest
//used in release()
using Address for address;

// ============ Events ============
Expand Down
52 changes: 52 additions & 0 deletions data/blacklist.json
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"
]

0 comments on commit 94af202

Please sign in to comment.