Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix robot nft tutorial part1 #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified static/images/tutorials/42-robot-nft-ethereum/get-one.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
25 changes: 21 additions & 4 deletions tutorials/42-build-a-robot-nft.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Let's start on our NFT contract code. Open `contract.sol`, delete the file's con

```solidity
// // SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
pragma solidity ^0.8.8;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
Expand Down Expand Up @@ -154,7 +154,7 @@ We'll start by defining a string array for each type of accessory. Add the follo
```solidity
string[] private headgear = [
"Cowboy Hat",
"Afro",
"Fro",
"Baseball Cap",
"Viking Helmet"
];
Expand Down Expand Up @@ -360,16 +360,33 @@ Connect your MetaMask wallet to the web interface and switch to the Replit Testn
![Switching to test](/images/tutorials/42-robot-nft-ethereum/switch-to-test.png)
![Getting one Ether](/images/tutorials/42-robot-nft-ethereum/get-one.png)

Now you can deploy your contracts. Select "ReplBot" from the drop-down box and click "Deploy". Approve the MetaMask pop-up that appears.
Now you can deploy your contracts. Select "ReplBots" from the drop-down box and click "Deploy". Approve the MetaMask pop-up that appears.

![Deploy the contract](/images/tutorials/42-robot-nft-ethereum/deploy.png)

<img src="/images/tutorials/42-robot-nft-ethereum/confirmdeploy.png"
alt="Confirm deploy"
style="Width: 50% !important;"/>


Once this contract has been deployed, it will show up as an expandable box below the drop-down box. Expand it and take a look at all the different functions available.

<video width="80%" autoplay loop>
<source src="/images/tutorials/42-robot-nft-ethereum/expand.mp4" type="video/mp4">
</video>

Mint your first NFT by navigating to the `mint` function. Click on your wallet address in the top right corner of the page to copy it, and then paste it into the `recipient` field. Then run the function and approve the MetaMask pop-up that appears.

<video width="80%" autoplay loop>
<source src="/images/tutorials/42-robot-nft-ethereum/mint.mp4" type="video/mp4">
</video>

After a few seconds, you should see a pop-up indicating that your transaction has gone through. Congratulations, you're the proud owner of a ReplBot NFT! Check out its colors and accessories by entering ID 0 into `botColors` and `botAccessories`.

If you mint again, you should receive a ReplBot with ID 1 and a different set of colors and accessories.

![Bot colors](/images/tutorials/42-robot-nft-ethereum/botcolors.png)

## Breeding bots

We can now mint ReplBots with random characteristics, which fulfills the specification we laid out at the start of this tutorial. But with a bit of additional code, we can introduce a second way to create ReplBots, breeding.
Expand Down Expand Up @@ -460,7 +477,7 @@ Next comes our bot creation code, which will be similar to the code in our `mint
uint8 faceIdx = uint8(_random(tokenId, "asdfg") % facegear.length);

// Create bot
replbots[tokenId] = ReplBot(frameCol, visorCol, backgroundCol, headIdx, earIdx, faceIdx, parentOne.generation + 1);
replbots[tokenId] = ReplBot(frameCol, visorCol, backgroundCol, headIdx, earIdx, faceIdx, parentOne.generation + 1, parentOneId, parentTwoId);

// Mint token
_safeMint(recipient, tokenId);
Expand Down