Last active
March 6, 2022 07:03
-
-
Save sarthakxv/bd25fa697968c10fd3dc9b455c32a586 to your computer and use it in GitHub Desktop.
marketplace
This file contains hidden or 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
| // hardhat.config.js | |
| require("@nomiclabs/hardhat-waffle"); | |
| require("dotenv").config(); | |
| module.exports = { | |
| solidity: "0.8.4", | |
| defaultNetwork: "rinkeby", | |
| networks: { | |
| hardhat: {}, | |
| rinkeby: { | |
| url: `https://eth-rinkeby.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`, | |
| accounts: [`0x${process.env.PRIVATE_KEY}`], | |
| }, | |
| }, | |
| paths: { | |
| sources: "./contracts", | |
| tests: "./test", | |
| cache: "./cache", | |
| artifacts: "./artifacts", | |
| }, | |
| mocha: { | |
| timeout: 20000, | |
| }, | |
| gas: 2100000, | |
| gasPrice: 8000000000, | |
| }; |
This file contains hidden or 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.4; | |
| import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
| import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
| import "@openzeppelin/contracts/access/Ownable.sol"; | |
| import "@openzeppelin/contracts/utils/Counters.sol"; | |
| import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | |
| import "hardhat/console.sol"; | |
| contract mintNfts is ERC721, ERC721URIStorage, Ownable { | |
| using Counters for Counters.Counter; | |
| Counters.Counter private _tokenIdCounter; | |
| constructor() ERC721("Shree", "SRE") {} | |
| function _baseURI() internal pure override returns (string memory) { | |
| return "https://jsonkeeper.com/b/1KV4"; | |
| } | |
| function safeMint(string memory uri) public onlyOwner { | |
| uint256 tokenId = _tokenIdCounter.current(); | |
| _tokenIdCounter.increment(); | |
| _safeMint(msg.sender, tokenId); | |
| _setTokenURI(tokenId, uri); | |
| } | |
| // The following functions are overrides required by Solidity. | |
| function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { | |
| super._burn(tokenId); | |
| } | |
| function tokenURI(uint256 tokenId) | |
| public | |
| view | |
| override(ERC721, ERC721URIStorage) | |
| returns (string memory) | |
| { | |
| return super.tokenURI(tokenId); | |
| } | |
| } |
This file contains hidden or 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
| // scripts/mintRun.js | |
| const mintRun = async () => { | |
| const CONTRACT_ADDRESS = "0x9A4Ea4Ec7f13d255bC9B855dcBb97595F1E49253"; | |
| const metadata = "https://jsonkeeper.com/b/1KV4"; | |
| const DropContractFactory = await hre.ethers.getContractFactory('mintNfts'); | |
| const dropContract = DropContractFactory.attach(CONTRACT_ADDRESS); | |
| console.log("Contract address:", dropContract.address); | |
| // for (let i = 0; i < address.length; i++) { | |
| try { | |
| let txn = await dropContract.safeMint(metadata); | |
| console.log("Mining, please wait..."); | |
| await txn.wait(); | |
| } catch (e) { | |
| console.log(e); | |
| } | |
| // } | |
| }; | |
| const runMintRun = async () => { | |
| try { | |
| await mintRun(); | |
| process.exit(0); | |
| } catch (error) { | |
| console.log(error); | |
| process.exit(1); | |
| } | |
| }; | |
| runMintRun(); |
This file contains hidden or 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
| // scripts/run.js | |
| const main = async () => { | |
| const nftContractFactory = await hre.ethers.getContractFactory('mintNfts'); | |
| const nftContract = await nftContractFactory.deploy(); | |
| await nftContract.deployed(); | |
| console.log("Contract deployed to:", nftContract.address); | |
| }; | |
| const runMain = async () => { | |
| try { | |
| await main(); | |
| process.exit(0); | |
| } catch (error) { | |
| console.log(error); | |
| process.exit(1); | |
| } | |
| }; | |
| runMain(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment