C 360: Making a NFT (15 pts extra)

What you need:

Background

NFT's are collectible items that consist of a record on a blockchain stating that you are regarded as the owner of a virtual object.

This ownership has no apparent value in the real world, but people are paying millions for them, assuming that someone else will pay even more for them, before the bubble bursts and everyone realizes what nonsense it all is.

In this project, you'll make an NFT on a free Ethereum testnet, so it won't cost any money to make and it won't be sold for any real money.

This project is based on this walkthrough.

Creating an Image

Create an image of vast artistic value, or download one, as shown below.

Using Pinata Cloud

In a Web browser, go to

https://www.pinata.cloud/

At the top right, click the "Try for free" button.

In the "Free plan" section, click the "Sign up now" button.

Fill in the form and register as a Creator.

Check your email and verify your account. You'll see a home page, as shown below.

Click the Upload buttom and upload your image.

You see a long CID number identifying your image, as shown below.

Creating a TokenURI

In a Text editor, create a file with these contents:
{
    "name": "SAM'S AWESOME NFT",
    "description": "BETTER THAN THE REST",
    "image": "https://cloudflare-ipfs.com/ipfs/Qmc8DshQjkKgdfnTxe4ruNApqRgVN2xGcgx5RYpT9Erei4",
    "attributes": [
        {
            "trait_type": "trait",
            "value": 100
        }
    ]
}
Make these modifications: Save the file with a filename ending in .json

Upload the .json file to Pinata, so you have two files, as shown below.

Getting some Rinkeby ETH

You can get it from these faucets, which may be slow:

https://faucet.rinkeby.io/

http://rinkeby-faucet.com/

https://faucets.chain.link/

Opening the Rinkeby LINK Faucet

In a Web browser, go to

https://faucets.chain.link/rinkeby

The faucet opens, as shown below.

Getting some Rinkeby LINK

You need to have Google Chrome, with the Metamask extension and an account containing some Ether on the Rinkeby test network, which you prepared in a previous project.

Launch Chrome. Then launch Metamask and log in.

You should see some Ether on the Rinkeby test network, as shown below.

The ETH you have can pay for on-chain transactions. But we also need to perform off-chain transactions, and for that, we need LINK tokens.

At the top center of MetaMask, below "Rinkeby Test Network", click your wallet name. In the image above, the name is "Account 2". This copies your account number to the clipboard.

Paste your account number into the Rinkeby LINK Faucet and follow the instructions on that page to request some LINK.

A "Request complete" message appears, as shown below.

Adding the Rinkeby LINK Token to Metamask

You can't see your LINK in Metamask until you add the token.

In Metamask, at botton, click the "Add Token" button.

Paste this value into the "Token Contract Address" field, as shown below.

0x01BE23585060835E02B77ef475b0Cc51aA1e0709

At the lower right, click the Next button.

Click the "Add Tokens" button.

Now you have some LINK, as shown below.

At the top left, click the <.

Your assets now include ETH and LINK, as shown below.

Create an Infura Account

In a Web browser, go to

https://infura.io/

At the top right, fill in the form and sign up, as shown below.

Check your email and verify your account.

You see the "Welcome" page. On the left side, click the ETHEREUM button.

Click the "CREATE A PROJECT" button, as shown below.

Give your project a name and click CREATE.

On the next page, at the bottom, in ENDPOINTS, select Rinkeby.

Now you have a PROJECT ID, as shown below.

Installing Required Software

On your Debian 10 machine, execute these commands, replacing the PROJECT ID in the first command with your correct PROJECT ID:
sudo apt update
sudo apt install nodejs npm -y
sudo apt install python3-pip git -y
python3 -m pip install eth-brownie
sudo npm install -g ganache-cli
Npm shows some warnings, as shown below. Ignore them.

Close the Terminal. Open a New Terminal and execute this command.

brownie
You see the brownie help message, as shown below.

Troubleshooting

If brownie is not found, execute this command to find it. The location is highlighted in the image below.
sudo find / -name "brownie"
And this command to add its location to the PATH, inserting the correct location after the equals sign:
export PATH=/home/headless/.local/bin/:$PATH

Execute this command, replacing the PROJECT ID with your correct PROJECT ID:
export WEB3_INFURA_PROJECT_ID=3552ff6466d14e05b072cda0f5ace990

Finding your Metamask Private Key

In Metamask, at the top right, click the three-dot icon. Then click "Account Details" and "Export Private Key".

Enter your password and click the Confirm button.

Your private key appears, as shown below.

On your Debian 10 machine, execute this command, replacing the number with your correct private key:

export PRIVATE_KEY=e9170000000000000000000000000000000000dde8f6

Deploying your NFT Contract

On your Debian 10 Linux machine, execute these commands:
git clone https://github.com/PatrickAlphaC/nft-mix
cd nft-mix
brownie run scripts/simple_collectible/deploy_simple.py --network rinkeby
Your contract is deployed, as shown below.

Notice that some of your ETH has been consumed, as shown below.

Creating the "PUG" Collectible

First we'll create an NFT from a "PUG" example image made by someone else.

On your Debian 10 Linux machine, execute this command:

brownie run scripts/simple_collectible/create_collectible.py --network rinkeby
Your NFT is generated, with a message saying "You can view your NTF at...", as shown below.

In a Web browser, go the URL indicated to see your PUG NFT, as shown below.

Creating your Custom NFT

On your Debian 10 Linux machine, execute these commands:
cp scripts/simple_collectible/create_collectible.py scripts/simple_collectible/create_my_NFT.py
nano scripts/simple_collectible/create_my_NFT.py
Replace the long string of letters in the "sample_token_uri" line with the CID number for the JSON file you uploaded to Pinata, as shown below.

Save the file with Ctrl+X, Y, Enter.

On your Debian 10 Linux machine, execute this command:

brownie run scripts/simple_collectible/create_my_NFT.py --network rinkeby
Your NFT is generated, with a message saying "You can view your NTF at...", as shown below.

In a Web browser, go the URL indicated to see your custom NFT, as shown below.

C 360.1 Token Standard (15 pts)

On the page showing your custom NFT, at the lower left, click Details.

The flag is covered by a green rectangle in the image below.

References

Posted 9-15-2021
ETH faucets added 10-7-21
PATH troubleshooting added 7-29-22