Comments (1)
Hey. If you question is about why cryptozombies.io use a mapping instead of adding owner as an attribute of the Zombie structure, I could explain it in a way i can.
Let's say we have already added owner as an attribute. This is what might happen:
In order to query who a zombie's owner is. We just need to use:
zombies[_tokenId].owner
.
It seems simpler. But truth is that every time we use:
Zombie storage myZombie = zombies[_tokenId]
This will cost more space because of one more attribute.
In Ethereum networks, space+time = money
. So you don't wanna spend extra fees.
The owner attribute is better be separated because the relations between the two things.
I.E. the relation between the attributes like name, dna ,etc.. and zombie is 1 (per attribute) :1 (per zombie)
. But for owner : zombie = 1 : many
.
So It makes perfect sense to make a zombieToOwner mapping.
Hope it helps.
If there is any error in the above explanation, please point it out. Thanks!!
Wanna contact me? [email protected]
from cryptozombie-lessons.
Related Issues (20)
- lesson 17 cant go next chapter HOT 1
- Lesson 3, Chapter 9: Might be nice to have the reminder of code checker limitations again HOT 2
- Unable to view Zombie Army.. browser is not rendering it?
- Lesson 5 chapter 1 code why must `pragma` replace `//Start here` comment on the first line?
- Lesson 5 chapter 8 is wrong?
- Login does not work anymore HOT 11
- I selected Japanese in the language settings, but some notations are displayed in Korean. HOT 1
- Connot register, there is something error. HOT 1
- Lesson 1 - Chapter 13 : Error in sample js implementation HOT 3
- Can't switch to th next chapter. HOT 2
- wrong pragma for lesson 1, chapter 11. HOT 1
- Unable to login HOT 1
- Can I reset my lessons progress? HOT 2
- Register is not working / Not able to register HOT 1
- lesson 19 chapter 8, wrong Solution?
- Not moving to next chapter after completing previous chapter HOT 1
- Outdated mention of consensus mechanism (proof of work)
- chapter 11
- Wrong typo for Lesson 16 chapter 9 HOT 1
- Wrong comment impact of Lesson 17 chapter 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptozombie-lessons.