Home

Awesome

DISCLAIMER

Hello Starknet community, this repository is not updated with the latest Cairo syntax and hence, we do not recommend to attempt this tutorial as of today. If you are interested in contributing to the repository to update the tutorial, please create a PR and tag me @gyan0890 on it and we will be happy to support you with the process.

A great resource to get you up to speed with the new Cairo syntax in a Starknet context is Chapter 2 of the Starknet Book.

You can also ping me(@gyanlakshmi) on Telegram to help you assign right tasks.

ERC721 on StarkNet

Welcome! This is an automated workshop that will explain how to deploy an ERC721 token on StarkNet and customize it to perform specific functions. The ERC721 standard is described here. It is aimed at developers that:

Introduction

Disclaimer

​ Don't expect any kind of benefit from using this, other than learning a bunch of cool stuff about StarkNet, the first general purpose validity rollup on the Ethereum Mainnet. ​ StarkNet is still in Alpha. This means that development is ongoing, and the paint is not dry everywhere. Things will get better, and in the meanwhile, we make things work with a bit of duct tape here and there! ​

How it works

The goal of this tutorial is for you to customize and deploy an ERC721 contract on StarkNet. Your progress will be check by an evaluator contract, deployed on StarkNet, which will grant you points in the form of ERC20 tokens.

Each exercise will require you to add functionality to your ERC721 token.

For each exercise, you will have to write a new version on your contract, deploy it, and submit it to the evaluator for correction.

Where am I?

This workshop is the second in a series aimed at teaching how to build on StarkNet. Checkout out the following:

TopicGitHub repo
Learn how to read Cairo codeCairo 101
Deploy and customize an ERC721 NFT (you are here)StarkNet ERC721
Deploy and customize an ERC20 tokenStarkNet ERC20
Build a cross layer applicationStarkNet messaging bridge
Debug your Cairo contracts easilyStarkNet debug
Design your own account contractStarkNet account abstraction

Providing feedback & getting help

Once you are done working on this tutorial, your feedback would be greatly appreciated!

Please fill out this form to let us know what we can do to make it better.

​ And if you struggle to move forward, do let us know! This workshop is meant to be as accessible as possible; we want to know if it's not the case.

​ Do you have a question? Join our Discord server, register, and join channel #tutorials-support ​ Are you interested in following online workshops about learning how to dev on StarkNet? Subscribe here

Contributing

This project can be made better and will evolve as StarkNet matures. Your contributions are welcome! Here are things that you can do to help:

Getting ready to work

Step 1 - Clone the repo

git clone https://github.com/starknet-edu/starknet-erc721
cd starknet-erc721

Step 2 - Set up your environment

There are two ways to set up your environment on StarkNet: a local installation, or using a docker container

For a production setup instructions we wrote this article.

Option A - Set up a local python environment

pip install openzeppelin-cairo-contracts

Option B - Use a dockerized environment

for mac m1:

alias cairo='docker run --rm -v "$PWD":"$PWD" -w "$PWD" shardlabs/cairo-cli:latest-arm'

for amd processors

alias cairo='docker run --rm -v "$PWD":"$PWD" -w "$PWD" shardlabs/cairo-cli:latest'
docker run --rm -it -v ${pwd}:/work --workdir /work shardlabs/cairo-cli:latest

Step 3 -Test that you are able to compile the project

starknet-compile contracts/Evaluator.cairo

​ ​

Working on the tutorial

Workflow

To do this tutorial you will have to interact with the Evaluator.cairo contract. To validate an exercise you will have to

For example to solve the first exercise the workflow would be the following:

deploy a smart contract that answers ex1call submit_exercise on the evaluator providing your smart contract addresscall ex1_test_erc721 on the evaluator contract

Your objective is to gather as many ERC721-101 points as possible. Please note :

Contracts code and addresses

Contract codeContract on voyager
Points counter ERC200xa0b943234522049dcdbd36cf9d5e12a46be405d6b8757df2329e6536b40707
Evaluator0x2d15a378e131b0a9dc323d0eae882bfe8ecc59de0eb206266ca236f823e0a15
Dummy ERC20 token0x52ec5de9a76623f18e38c400f763013ff0b3ff8491431d7dc0391b3478bf1f3
Dummy ERC721 token0x4fc25c4aca3a8126f9b386f8908ffb7518bc6fefaa5c542cd538655827f8a21

​ ​

Tasks list

Today we are creating an animal registry! Animals are bred by breeders. They can be born, die, reproduce, be sold. You will implement these features little by little.

Exercise 1 - Deploying an ERC721

starknet-compile contracts/ERC721/ERC721.cairo --output artifacts/ERC721.json
starknet deploy --contract artifacts/ERC721.json --inputs arg1 arg2 arg3 --network alpha-goerli 

Exercise 2 - Creating token attributes

Exercise 3 - Minting NFTs

Exercise 4 - Burning NFTs

Exercise 5 - Adding permissions and payments

Exercise 6 - Claiming an NFT

Exercise 7 - Adding metadata

Annex - Useful tools

Converting data to and from decimal

To convert data to felt use the utils.py script To open Python in interactive mode after running script

python -i utils.py
>>> str_to_felt('ERC20-101')
1278752977803006783537

Checking your progress & counting your points

​ Your points will get credited in your wallet; though this may take some time. If you want to monitor your points count in real time, you can also see your balance in voyager! ​

You can also check your overall progress here

Transaction status

​ You sent a transaction, and it is shown as "undetected" in voyager? This can mean two things: ​