Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
.DS_Store

node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 150
}
Empty file added README.md
Empty file.
88 changes: 88 additions & 0 deletions contracts/BaseNFT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: LICENSE
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

contract NFTMarketplace is ERC721URIStorage, ReentrancyGuard {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;

address payable owner;
uint256 private maxSupply = 100_000;
string private contractMetadata;

modifier onlyOwner() {
require(owner == msg.sender, "Only Contract Owner can access this");
_;
}

constructor(string memory name, string memory symbol) ERC721(name, symbol) {
owner = payable(msg.sender);
}

function getNftName() external view returns (string memory) {
return name();
}

function getNftSymbol() external view returns (string memory) {
return symbol();
}

function getMetadata(
uint256 tokenId
) external view returns (string memory) {
return tokenURI(tokenId);
}

/** to retrieve contract-level metadata (this will be accessed by OpenSea) */
function getContractURI() public view returns (string memory) {
return contractMetadata;
}

/** Sets contract-level metadata */
function setContractURI(string memory metadataURI) external onlyOwner {
contractMetadata = metadataURI;
}

function getMaxSupply() external view returns (uint256) {
return maxSupply;
}

/** To update max supply on demand */
function updateMaxSupply(uint256 _maxSupply) public onlyOwner {
maxSupply = _maxSupply;
}

/** Mints a token */
function mintToken(
string memory tokenURI
) external onlyOwner returns (uint) {
uint256 currentTokenId = _tokenIds.current();
require(currentTokenId < maxSupply, "Marketplace max supply reached");

_tokenIds.increment();
uint256 newTokenId = _tokenIds.current();

_mint(msg.sender, newTokenId);
_setTokenURI(newTokenId, tokenURI);
return newTokenId;
}

/** Burns a token */
function burnToken(uint256 tokenId) external onlyOwner {
// require(_ownerOf(tokenId) == msg.sender, 'Only item owner can perform this operation');
_burn(tokenId);
}

/** Transfers token from one adress to other */
function transfer(
address from,
address to,
uint256 tokenId
) external onlyOwner {
_transfer(from, to, tokenId);
}
}
28 changes: 28 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';

const { NETWORK, ACCOUNT_PRIVATE_KEY, POLYGONSCAN_KEY } = process.env;

const config: HardhatUserConfig = {
solidity: '0.8.19',
defaultNetwork: NETWORK,
networks: {
matic_mumbai: {
url: 'https://rpc-mumbai.maticvigil.com',
chainId: 80001,
accounts: [ACCOUNT_PRIVATE_KEY!],
},
polygon: {
url: 'https://polygon-mainnet.infura.io',
chainId: 137,
accounts: [ACCOUNT_PRIVATE_KEY!],
},
},
etherscan: {
apiKey: {
polygonMumbai: POLYGONSCAN_KEY!,
},
},
};

export default config;
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "staked_steps",
"author": "Mohan Vaddi <myselfgeek01@gmail.com>",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"compile": "npx hardhat compile --force --show-stack-traces",
"clean": "npx hardhat clean",
"dev": "ts-node-dev --require dotenv/config --respawn --transpile-only src/server.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"compile:deploy": "npx hardhat compile && npx ts-node scripts/deploy.ts",
"prepare": "husky install",
"test": "jest 'src/__specs__/'",
"test:watch": "jest 'src/__specs__/' --watch",
"test:cov": "jest 'src/__specs__/' --coverage --silent",
"test:contract": "jest 'contracts/__specs__' --detectOpenHandles --forceExit",
"set:env": "ts-node node-scripts/env-setup.ts",
"start:local": "TARGET_ENV=local npm run set:env && npm run dev",
"start:dev": "TARGET_ENV=dev npm run set:env && npm run dev",
"start:prod": "TARGET_ENV=prod npm run set:env && npm run dev"
},
"keywords": [],
"license": "ISC",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@types/express": "^4.17.21",
"hardhat": "^2.22.2",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.4.4"
},
"dependencies": {
"@openzeppelin/contracts": "^5.0.2",
"dotenv": "^16.4.5",
"express": "^4.19.2"
}
}
Loading