This repository contains an ERC-721 token smart contract and some auxiliary code to test and deploy the contract.
- Install Node.js
- Clone this repository
- Navigate to the directory with the cloned code
- Install Hardhat with
npm install --save-dev hardhat
- Create a MetaMask wallet
- Install MetaMask Chrome extension
- Add Polygon Mainnet to MetaMask
- Switch to Polygon Mainnet
- Create a file called
.env
in the root of the project with the same contents as.env.example
- Copy your private key from MetaMask to
.env
file
POLYGON_PRIVATE_KEY=***your private key from MetaMask***
- Create an account on Polygonscan
- Go to "My Profile" - "API_KEYs"
- Create a new API KEY
- Copy "Api-Key Token"
- Copy your Polygonscan API KEY to
.env
file
POLYGONSCAN_API_KEY=***your API key from Polygonscan***
Next steps will show you how to build and deploy the contract 💻.
npx hardhat compile
npx hardhat test
Move to the "Deploy" step only if all tests pass!
а) Mumbai test network
Make sure you have enough MATIC for testnet. You can get it for free from faucet.
npx hardhat run scripts/deploy.js --network mumbai
b) Polygon main network
Make sure you have enough MATIC in your wallet. Deployment to the mainnet costs real MATIC!
npx hardhat run scripts/deploy.js --network polygon
Deployment script takes more than 1.5 minutes to complete. Please, be patient.
After the contract gets deployed and verified you can find its address in the deployOutput.json
file. Use it to interact with the contract.
giveMeToken
:
- Issues one (and only one) token for the caller
- Can be called by anyone
- No additional payments except for gas fees
Please note that the function requires a uri
string as a parameter.