Skip to content

buildwithcode888/NFT-contract

Repository files navigation

Random Emoji NFT collection on OpenSea

This demo project demonstrates how to create randomly generated on-chain Emoji NFTs using Chainlink VRF and how to host that collection on OpenSea on Sepolia Testnet.

What we are building

demo

Getting started

Prerequisites

Be sure to have installed the following

Installation

  1. Get a RPC API Key from a node provider such as Alchemy, Infura, Moralis, or QuickNode. This example uses the Sepolia Ethereum test network.
  2. Clone the repo
git clone https://github.com/smartcontractkit/smart-contract-examples.git
  1. Enter the directory
cd smart-contract-examples/random-svg-nft

Build and Deploy

  1. Install packages
yarn
  1. Compile contracts
yarn compile
  1. Run tests
yarn test

or

REPORT_GAS=true yarn test
  1. Run test coverage
yarn coverage
  1. Deploy contract to Sepolia

Go to Chainlink VRF Subscription Managment Page, connect your wallet, create new subscription and fund it. Make sure to have at least 1 Sepolia LINK in your wallet, you can obtain it from the Chainlink Faucet

Copy the .env.example file to a file named .env, and put your Private Key, RPC API Key, Etherscan API Key, and Subscription ID like this

ETHERSCAN_API_KEY=<YOUR ETHERSCAN API>
SEPOLIA_URL=https://eth-sepolia.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=<YOUR PRIVATE KEY>
SUBSCRIPTION_ID=<ID>

After that run the deployment script which will

  • deploy your smart contract to the Sepolia
  • verify it on Etherscan
yarn deploy

Lastly, navigate back to the Chainlink VRF Subscription Managment Page and add the address of deployed smart contract as subscription consumer.

If the verification process fails because the new contract hasn't been indexed yet on Etherscan, run the next command from your terminal

npx hardhat verify --network Sepolia <CONTRACT_ADDRESS> 0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc <SUBSCRIPTION_ID> 1000000 4 3

Minting

Call mint() function of your contract. Soon after the successful transaction, your NFT will be available on OpenSea

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors