├── .gitignore ├── LICENSE ├── README.md ├── contracts └── NFT.sol ├── hardhat.config.js ├── package.json └── scripts └── deploy.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | artifacts 3 | cache 4 | package-lock.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 OpenSea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nft-tutorial 2 | A very basic NFT tutorial repository for absolute beginners in the world of Web3 and smart contracts 3 | 4 | The completed version of the code developed by following our tutorial for NFT beginners [here](https://docs.opensea.io/docs/creating-an-nft-contract) 5 | 6 | You'll need to update the environment variables `ALCHEMY_KEY` and `ACCOUNT_PRIVATE_KEY` in order to compile hardhat. You can learn more about where to get them [here](https://docs.alchemy.com/alchemy/tutorials/sending-txs). 7 | 8 | [![Run on Repl.it](https://repl.it/badge/github/plibither8/2048.cpp)](https://replit.com/@openseaofficial/nft-tutorial) 9 | -------------------------------------------------------------------------------- /contracts/NFT.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 5 | import "@openzeppelin/contracts/utils/Counters.sol"; 6 | 7 | contract NFT is ERC721 { 8 | using Counters for Counters.Counter; 9 | Counters.Counter private currentTokenId; 10 | 11 | constructor() ERC721("NFTTutorial", "NFT") {} 12 | 13 | function mintTo(address recipient) 14 | public 15 | returns (uint256) 16 | { 17 | currentTokenId.increment(); 18 | uint256 newItemId = currentTokenId.current(); 19 | _safeMint(recipient, newItemId); 20 | return newItemId; 21 | } 22 | } -------------------------------------------------------------------------------- /hardhat.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type import('hardhat/config').HardhatUserConfig 3 | */ 4 | 5 | require('dotenv').config(); 6 | require("@nomiclabs/hardhat-ethers"); 7 | 8 | const { ALCHEMY_KEY, ACCOUNT_PRIVATE_KEY } = process.env; 9 | 10 | module.exports = { 11 | solidity: "0.8.0", 12 | defaultNetwork: "rinkeby", 13 | networks: { 14 | hardhat: {}, 15 | rinkeby: { 16 | url: `https://eth-rinkeby.alchemyapi.io/v2/${ALCHEMY_KEY}`, 17 | accounts: [`0x${ACCOUNT_PRIVATE_KEY}`] 18 | }, 19 | ethereum: { 20 | chainId: 1, 21 | url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`, 22 | accounts: [`0x${ACCOUNT_PRIVATE_KEY}`] 23 | }, 24 | }, 25 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nft-tutorial", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@nomiclabs/hardhat-ethers": "^2.0.2", 13 | "@nomiclabs/hardhat-etherscan": "^3.0.0", 14 | "ethers": "^5.5.2", 15 | "hardhat": "^2.7.0", 16 | "node-fetch": "^2.6.6" 17 | }, 18 | "dependencies": { 19 | "@openzeppelin/contracts": "^4.4.0", 20 | "dotenv": "^10.0.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /scripts/deploy.js: -------------------------------------------------------------------------------- 1 | async function main() { 2 | 3 | // Get our account (as deployer) to verify that a minimum wallet balance is available 4 | const [deployer] = await ethers.getSigners(); 5 | 6 | console.log(`Deploying contracts with the account: ${deployer.address}`); 7 | console.log(`Account balance: ${(await deployer.getBalance()).toString()}`); 8 | 9 | // Fetch the compiled contract using ethers.js 10 | const NFT = await ethers.getContractFactory("NFT"); 11 | // calling deploy() will return an async Promise that we can await on 12 | const nft = await NFT.deploy(); 13 | 14 | console.log(`Contract deployed to address: ${nft.address}`); 15 | } 16 | 17 | main() 18 | .then(() => process.exit(0)) 19 | .catch((error) => { 20 | console.error(error); 21 | process.exit(1); 22 | }); --------------------------------------------------------------------------------