Home

Awesome

ERC721 on StarkNet

Introduction

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:

​ This workshop is the second in a series that will cover broad smart contract concepts (writing and deploying ERC20/ERC721, bridging assets, L1 <-> L2 messaging...). You can find the first tutorial here Interested in helping writing those? Reach out!

Table of contents

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 Mainnnet. ​ 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! ​

Providing feedback

Once you are done working on this tutorial, your feedback would be greatly appreciated! Please fill 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 ​

How to work on this tutorial

Before you start

The TD has three components:

Workflow

To do this tutorial you will have to interact with the Evaluator.cairo contract. To do an exercise you will have to use the submit_exercise function to tell the evaluator the address of the evaluated contract. Once it's done you can call the evaluator for it to correct the desired exericse. 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 :

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: ​

Install cairo-lang

With pip
pip install openzeppelin-cairo-contracts
With docker

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

Getting to work

starknet-compile contracts/Evaluator.cairo

Contract addresses

Contract codeContract on voyager
Points counter ERC200x0272abeb08a98ce2024b96dc522fdcf71e91bd333b228ad62ca664920881bc52
Evaluator0x03b56add608787daa56932f92c6afbeb50efdd78d63610d9a904aae351b6de73
Dummy ERC20 token0x07ff0a898530b169c5fe6fed9b397a7bbd402973ce2f543965f99d6d4a4c17b8
Dummy ERC721 token0x02e24bd7683c01cb2e4e48148e254f2a0d44ee526cff3c703d6031a685f1700d

Points 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.

ERC721 basics

Exercise 1

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

Exercise 2

Minting and burning NFTs

Exercise 3

Exercicse 4

Adding permissions and payments

Exercise 5

Minting NFTs with Metadata

Exercise 6

Exercise 7

Disclaimer This exercise can't be solved due to a typo, this will soon be fixed

​ ​