Skip to content

Commit

Permalink
Merge branch 'master' into lang-ko-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
studroid authored Jan 31, 2018
2 parents 46b5b09 + 49c14e9 commit ce0a3ce
Show file tree
Hide file tree
Showing 58 changed files with 2,023 additions and 250 deletions.
10 changes: 5 additions & 5 deletions en/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"Share this URL so your friends can check out your army:"
],
"footer": [
"Lesson 4 coming in 1-2 weeks",
"You'll get an email from us as soon as it's ready.",
"In the meantime, join us on {telegramLink}, or follow our {twitterLink} to join the conversation!"
"Enjoying CryptoZombies? Let us know!",
"Join the conversation on {telegramLink}, or follow us on {twitterLink}",
"When you're ready, click the button below to access Lesson 4:"
],
"zombieDesc": "A Level 3 CryptoZombie",
"shareLinkText": "I just completed #CryptoZombies Lesson 3! Check out my zombie army:"
Expand All @@ -113,7 +113,7 @@
"In the meantime, join us on {telegramLink}, or follow our {twitterLink} to join the conversation!"
],
"zombieDesc": "A Level {levelNum} CryptoZombie",
"shareLinkText": "I just completed #CryptoZombies Lesson 4! Check out my zombie army:"
"shareLinkText": "I just completed #CryptoZombies Lesson 4, and defeated the evil IOTA zombie! Try it out yourself:"
}
},
"zombieBattle": {
Expand Down Expand Up @@ -218,7 +218,7 @@
},
"lesson4": {
"achievementPreamble": [
"Your friend has completed CryptoZombies Lesson 4, and defeated the evil Iota zombie!",
"Your friend has completed CryptoZombies Lesson 4, and defeated the evil IOTA zombie!",
"Go ahead and try it for yourself to the left. Use your friend's army to engage in battle!",
"In order to complete Lesson 4 of CryptoZombies, your friend learned about:"
],
Expand Down
4 changes: 2 additions & 2 deletions en/share-template-msgs.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ogDesc": "I just completed CryptoZombies Lesson 3! My zombie army is growing..."
},
"4": {
"pageTitle": "Check out my IOTA0killer!",
"ogDesc": "I just completed CryptoZombies Lesson 4! My zombie won its first battle!"
"pageTitle": "My CryptoZombie defeated the evil IOTA zombie!",
"ogDesc": "I just completed CryptoZombies Lesson 4, and defeated the evil IOTA zombie! Come relive the battle..."
}
}
6 changes: 3 additions & 3 deletions fr/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"Partagez cette URL afin que vos amis puissent voir votre armรฉe :"
],
"footer": [
"La Leรงon 4 arrive dans 1 ร  2 semaines",
"On vous prรฉviendra par mail quand elle sera prรชte.",
"En attendant, rejoignez nous sur {telegramLink}, ou suivez nous sur {twitterLink} pour participer ร  la conversation !"
"Vous aimez CryptoZombies? Laissez-nous savoir !",
"Rejoignez la conversation sur {telegramLink}, ou suivez-nous sur {twitterLink}",
"Quand vous รชtes prรชt, cliquez sur le bouton pour accรฉder ร  la Leรงon 4 :"
],
"zombieDesc": "Un CryptoZombie de Niveau 3",
"shareLinkText": "Je viens juste de finir la Leรงon 3 de #CryptoZombies ! Viens voir mon armรฉe de zombie :"
Expand Down
6 changes: 3 additions & 3 deletions jp/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"ใ“ใฎURLใ‚’้€ใ‚Œใฐๅ‹้”ใฏใ„ใคใงใ‚‚ใ‚พใƒณใƒ“่ปๅ›ฃใ‚’่ฆ‹ใ‚Œใ‚‹ใž๏ผš"
],
"footer": [
"ใƒฌใƒƒใ‚นใƒณ 4ใฏใ€1-2้€ฑ้–“ๅพŒใซใƒชใƒชใƒผใ‚นไบˆๅฎšใงใ™",
"ใƒชใƒชใƒผใ‚นใ—ใŸใ‚‰ใ™ใใซใƒกใƒผใƒซใ‚’ใŠ้€ใ‚Šใ—ใพใ™ใ€‚",
"{telegramLink}ใซๅ‚ๅŠ ใ™ใ‚‹ใ‹, {twitterLink}ใ‚’ใƒ•ใ‚ฉใƒญใƒผใ—ใฆๆœ€ๆ–ฐๆƒ…ๅ ฑใ‚’ใƒใ‚งใƒƒใ‚ฏใงใใพใ™๏ผ"
"CryptoZombiesใฏใ„ใ‹ใŒใงใ—ใŸใ‹๏ผŸใ”ๆ„Ÿๆƒณใ‚’ใ“ใกใ‚‰ใงๅ—ใ‘ไป˜ใ‘ใฆใ„ใพใ™",
"{telegramLink}ใซๅ‚ๅŠ ใ™ใ‚‹ใ‹, {twitterLink}ใ‚’ใƒ•ใ‚ฉใƒญใƒผ",
"ๆบ–ๅ‚™ใŒใงใใŸใ‚‰ใ€ไธ‹ใฎใƒœใ‚ฟใƒณใ‚’ๆŠผใ™ใจใƒฌใƒƒใ‚นใƒณ4ใซ้€ฒใฟใพใ™๏ผš"
],
"zombieDesc": "ใ‚ฏใƒชใƒ—ใƒˆใ‚พใƒณใƒ“ใ€€ใƒฌใƒ™ใƒซ 3",
"shareLinkText": "#CryptZombiesใฎใƒฌใƒƒใ‚นใƒณ3ใŒ็ต‚ใ‚ใฃใŸใ‚ˆ๏ผไฝœใฃใŸใ‚พใƒณใƒ“่ปๅ›ฃใฏใ“ใ‚“ใชๆ„Ÿใ˜:"
Expand Down
11 changes: 11 additions & 0 deletions ko/2/00-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: ์ข€๋น„๊ฐ€ ํฌ์ƒ๋ฌผ์„ ๊ณต๊ฒฉํ•˜๋‹ค
header: ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ์ž๋„ค๊ฐ€ ๋ ˆ์Šจ 2์— ์™”๋‹ค๋Š” ๊ฑฐ๊ตฐ!
roadmap: roadmap2.jpg
---

ํ›Œ๋ฅญํ•˜๋‹ค, ์ธ๊ฐ„์ด์—ฌ! ๋‚ด๊ฐ€ ์ƒ๊ฐํ–ˆ๋˜ ๊ฒƒ๋ณด๋‹ค ์ž๋„ค๊ฐ€ ์ฝ”๋”ฉ์„ ๋” ์ž˜ํ•˜๋Š”๊ตฐ.

๋ ˆ์Šจ 2๋Š” **์ข€๋น„์—๊ฒŒ ๋‹ค๋ฅธ ์ƒ๋ช…์ฒด๋ฅผ ๋จน์—ฌ์„œ ์ข€๋น„ ๊ตฐ๋Œ€์˜ ๊ทœ๋ชจ๋ฅผ ๋Š˜๋ฆฌ๋Š” ๋ฐฉ๋ฒ•์„** ์ž๋„ค์—๊ฒŒ ๊ฐ€๋ฅด์ณ ์ค„ ๊ฑธ์„ธ.

์ด ๋ ˆ์Šจ์—์„œ ๋ช‡ ๊ฐ€์ง€ ๊ณ ๊ธ‰ ์†”๋ฆฌ๋””ํ‹ฐ ๊ฐœ๋…์— ๋Œ€ํ•ด ๋‹ค๋ฃฐ ๊ฒƒ์ด๋‹ˆ, ์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ๋ ˆ์Šจ 1์„ ์™„๋ฃŒํ•˜๋Š” ๊ฑธ ๊ฐ•๋ ฅ ์ถ”์ฒœํ•˜๋„ค.
34 changes: 34 additions & 0 deletions ko/2/1-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: ๋ ˆ์Šจ 2 ๊ฐœ์š”
actions: ['์ •๋‹ต ํ™•์ธํ•˜๊ธฐ', 'ํžŒํŠธ ๋ณด๊ธฐ']
material:
saveZombie: false
zombieBattle:
zombie:
lesson: 1
humanBattle: true
ignoreZombieCache: true
answer: 1
---

์ง€๋‚œ ๋ ˆ์Šจ์—์„œ ์ข€๋น„์˜ ์ด๋ฆ„์„ ๋ฐ›์•„์„œ ๋žœ๋ค์œผ๋กœ ์ข€๋น„๋ฅผ ์ƒ์„ฑํ•œ ๋‹ค์Œ, ์ด ์ข€๋น„๋ฅผ ๋ธ”๋ก์ฒด์ธ ์ƒ์˜ ์šฐ๋ฆฌ ์•ฑ ์ข€๋น„ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ถ”๊ฐ€ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ƒ์„ฑํ–ˆ์ง€.

์ด๋ฒˆ ๋ ˆ์Šจ์—์„œ๋Š” ์šฐ๋ฆฌ ์•ฑ์„ ์ข€ ๋” ๊ฒŒ์ž„๋‹ต๊ฒŒ ๋งŒ๋“ค ๊ฑธ์„ธ: ์•ฑ์„ ๋ฉ€ํ‹ฐํ”Œ๋ ˆ์ด์–ด ๊ฒŒ์ž„์œผ๋กœ ๋งŒ๋“ค๊ณ , ์ข€๋น„๋ฅผ ๋žœ๋ค์œผ๋กœ๋งŒ ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ  ์ข€๋” ์žฌ๋ฏธ์žˆ๋Š” ๋ฐฉ์‹์œผ๋กœ ์ข€๋น„๋ฅผ ์ƒ์„ฑํ•  ๊ฒƒ์ด๋„ค.

์–ด๋–ป๊ฒŒ ์ƒˆ๋กœ์šด ์ข€๋น„๋ฅผ ์ƒ์„ฑํ• ๊นŒ? ์ข€๋น„๊ฐ€ ๋‹ค๋ฅธ ์ƒ๋ช…์ฒด๋ฅผ "๋จน๋„๋ก" ํ•ด์„œ!

## ์ข€๋น„ ๋จน์ด๊ธฐ

์ข€๋น„๊ฐ€ ๋จน์ด๋ฅผ ๋จน์„ ๋•Œ ๋จน์ด๋Š” ๋ฐ”์ด๋Ÿฌ์Šค์— ๊ฐ์—ผ๋˜๊ฒŒ ๋˜์ง€. ์ด ๋ฐ”์ด๋Ÿฌ์Šค๋Š” ๋จน์ด๋ฅผ ์ƒˆ๋กœ์šด ์ข€๋น„๋กœ ๋ฐ”๊พธ์–ด ์ข€๋น„ ๊ตฐ๋Œ€์˜ ์ผ์›์ด ๋˜๋„๋ก ํ•˜์ง€. ์ƒˆ๋กœ์šด ์ข€๋น„์˜ DNA๋Š” ์ด์ „ ์ข€๋น„์˜ DNA์™€ ๋จน์ด์˜ DNA๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ณ„์‚ฐ๋  ๊ฒƒ์ด๋„ค.

๊ทธ๋Ÿผ ์šฐ๋ฆฌ ์ข€๋น„๋“ค์ด ๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ๋จน์ด๊ฐ€ ๋ฌด์—‡์ผ๊นŒ?

๊ทธ๊ฑธ ์•Œ๊ณ  ์‹ถ์œผ๋ฉด... ๋ ˆ์Šจ 2๋ฅผ ๋งˆ์ณ์•ผ ํ•  ๊ฒƒ์ด๋„ค!

# ์ง์ ‘ ํ•ด๋ณด๊ธฐ

์˜ค๋ฅธ์ชฝ์— ๋ณด๋ฉด ์ข€๋น„๊ฐ€ ๋จน์ด๋ฅผ ๋จน๋Š” ๊ฐ„๋‹จํ•œ ๋ฐ๋ชจ๊ฐ€ ์žˆ์ง€. ์ธ๊ฐ„์„ ํด๋ฆญํ•ด์„œ ์ข€๋น„๊ฐ€ ๋จน์ด๋ฅผ ๋จน์„ ๋•Œ ์–ด๋–ค ์ผ์ด ์ผ์–ด๋‚˜๋Š”์ง€ ๋ณด๊ฒŒ!

์ƒˆ๋กœ์šด ์ข€๋น„์˜ DNA๊ฐ€ ์›๋ž˜ ์ข€๋น„์˜ DNA์™€ ๋จน์ด์˜ DNA์— ์˜ํ•ด ๊ฒฐ์ •๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์ง€.

์ค€๋น„๊ฐ€ ๋˜๋ฉด, "๋‹ค์Œ ์ฑ•ํ„ฐ"๋ฅผ ํด๋ฆญํ•ด์„œ ๊ณ„์† ์ง„ํ–‰ํ•˜๊ฒŒ. ์šฐ๋ฆฌ ๊ฒŒ์ž„์„ ๋ฉ€ํ‹ฐ ํ”Œ๋ ˆ์ด์–ด ๊ฒŒ์ž„์œผ๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋„๋ก ํ•˜์ง€.
193 changes: 193 additions & 0 deletions ko/2/10-interactingcontracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
---
title: ์ข€๋น„๊ฐ€ ๋ฌด์—‡์„ ๋จน๋‚˜์š”?
actions: ['์ •๋‹ต ํ™•์ธํ•˜๊ธฐ', 'ํžŒํŠธ ๋ณด๊ธฐ']
material:
editor:
language: sol
startingCode:
"zombiefeeding.sol": |
pragma solidity ^0.4.19;
import "./zombiefactory.sol";
// ์—ฌ๊ธฐ์— KittyInterface๋ฅผ ์ƒ์„ฑํ•œ๋‹ค
contract ZombieFeeding is ZombieFactory {
function feedAndMultiply(uint _zombieId, uint _targetDna) public {
require(msg.sender == zombieToOwner[_zombieId]);
Zombie storage myZombie = zombies[_zombieId];
_targetDna = _targetDna % dnaModulus;
uint newDna = (myZombie.dna + _targetDna) / 2;
_createZombie("NoName", newDna);
}
}
"zombiefactory.sol": |
pragma solidity ^0.4.19;
contract ZombieFactory {
event NewZombie(uint zombieId, string name, uint dna);
uint dnaDigits = 16;
uint dnaModulus = 10 ** dnaDigits;
struct Zombie {
string name;
uint dna;
}
Zombie[] public zombies;
mapping (uint => address) public zombieToOwner;
mapping (address => uint) ownerZombieCount;
function _createZombie(string _name, uint _dna) internal {
uint id = zombies.push(Zombie(_name, _dna)) - 1;
zombieToOwner[id] = msg.sender;
ownerZombieCount[msg.sender]++;
NewZombie(id, _name, _dna);
}
function _generateRandomDna(string _str) private view returns (uint) {
uint rand = uint(keccak256(_str));
return rand % dnaModulus;
}
function createRandomZombie(string _name) public {
require(ownerZombieCount[msg.sender] == 0);
uint randDna = _generateRandomDna(_name);
_createZombie(_name, randDna);
}
}
answer: >
pragma solidity ^0.4.19;
import "./zombiefactory.sol";
contract KittyInterface {
function getKitty(uint256 _id) external view returns (
bool isGestating,
bool isReady,
uint256 cooldownIndex,
uint256 nextActionAt,
uint256 siringWithId,
uint256 birthTime,
uint256 matronId,
uint256 sireId,
uint256 generation,
uint256 genes
);
}
contract ZombieFeeding is ZombieFactory {
function feedAndMultiply(uint _zombieId, uint _targetDna) public {
require(msg.sender == zombieToOwner[_zombieId]);
Zombie storage myZombie = zombies[_zombieId];
_targetDna = _targetDna % dnaModulus;
uint newDna = (myZombie.dna + _targetDna) / 2;
_createZombie("NoName", newDna);
}
}
---

์ด์ œ ์ข€๋น„๋“ค์—๊ฒŒ ๋จน์ด๋ฅผ ์ค„ ์‹œ๊ฐ„์ด๊ตฐ! ์ข€๋น„๊ฐ€ ๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ๋จน์ด๊ฐ€ ๋ญ˜๊นŒ?

ํฌ๋ฆฝํ† ์ข€๋น„๊ฐ€ ๊ฐ€์žฅ ์ข‹์•„ํ•˜๋Š” ๋จน์ด๋Š”...

**ํฌ๋ฆฝํ† ํ‚คํ‹ฐ!** ๐Ÿ˜ฑ๐Ÿ˜ฑ๐Ÿ˜ฑ

(๊ทธ๋ž˜, ์ •๋ง์ด๋ผ๋„ค ๐Ÿ˜† )

์ข€๋น„์—๊ฒŒ ํฌ๋ฆฝํ† ํ‚คํ‹ฐ๋ฅผ ๋จน์ด๋กœ ์ฃผ๋ ค๋ฉด ํฌ๋ฆฝํ† ํ‚คํ‹ฐ ์Šค๋งˆํŠธ ์ปจํŠธ๋ ‰ํŠธ์—์„œ ํ‚คํ‹ฐ DNA๋ฅผ ์ฝ์–ด์™€์•ผ ํ•  ๊ฒƒ์ด๋„ค. ์ด๊ฒŒ ๊ฐ€๋Šฅํ•œ ์ด์œ ๋Š” ํฌ๋ฆฝํ† ํ‚คํ‹ฐ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ธ”๋ก์ฒด์ธ ์ƒ์— ๊ณต๊ฐœ์ ์œผ๋กœ ์ €์žฅ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด์ง€. ๋ธ”๋ก์ฒด์ธ์ด ํ™˜์ƒ์ ์ด์ง€ ์•Š๋‚˜?!

๊ฑฑ์ • ๋ง๊ฒŒ - ์šฐ๋ฆฌ ๊ฒŒ์ž„์ด ์–ด๋Š ๋ˆ„๊ตฌ์˜ ํฌ๋ฆฝํ† ํ‚คํ‹ฐ์—๊ฒŒ๋„ ์‹ค์ œ ํ•ด๋ฅผ ๋ผ์น˜์ง€ ์•Š์„ ๊ฒƒ์ด๋‹ˆ ๋ง์ผ์„ธ. ์šฐ๋ฆฐ ๋‹จ์ง€ ํฌ๋ฆฝํ† ํ‚คํ‹ฐ ๋ฐ์ดํ„ฐ๋ฅผ *์ฝ์–ด ์˜ฌ* ๋ฟ์ด์ง€. ์‹ค์ œ๋กœ ์ด ๋ฐ์ดํ„ฐ๋ฅผ ์ง€์šธ ์ˆ˜๋Š” ์—†๋‹ค๋„ค. ๐Ÿ˜‰

## ๋‹ค๋ฅธ ์ปจํŠธ๋ ‰ํŠธ์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ธฐ

๋ธ”๋ก์ฒด์ธ ์ƒ์— ์žˆ์œผ๋ฉด์„œ ์šฐ๋ฆฌ๊ฐ€ ์†Œ์œ ํ•˜์ง€ ์•Š์€ ์ปจํŠธ๋ ‰ํŠธ์™€ ์šฐ๋ฆฌ ์ปจํŠธ๋ ‰ํŠธ๊ฐ€ ์ƒํ˜ธ์ž‘์šฉ์„ ํ•˜๋ ค๋ฉด ์šฐ์„  **_์ธํ„ฐํŽ˜์ด์Šค_**๋ฅผ ์ •์˜ํ•ด์•ผ ํ•˜๋„ค.

๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด ๋ณด๋„๋ก ํ•˜์ง€. ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ธ”๋ก์ฒด์ธ ์ปจํŠธ๋ ‰ํŠธ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•ด ๋ณด์„ธ:

```
contract LuckyNumber {
mapping(address => uint) numbers;
function setNum(uint _num) public {
numbers[msg.sender] = _num;
}
function getNum(address _myAddress) public view returns (uint) {
return numbers[_myAddress];
}
}
```

์ด ์ปจํŠธ๋ ‰ํŠธ๋Š” ์•„๋ฌด๋‚˜ ์ž์‹ ์˜ ํ–‰์šด์˜ ์ˆ˜๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ„๋‹จํ•œ ์ปจํŠธ๋ ‰ํŠธ์ด๊ณ , ๊ฐ์ž์˜ ์ด๋”๋ฆฌ์›€ ์ฃผ์†Œ์™€ ์—ฐ๊ด€์ด ์žˆ์„ ๊ฒƒ์ด๋„ค. ์ด ์ฃผ์†Œ๋ฅผ ์ด์šฉํ•ด์„œ ๋ˆ„๊ตฌ๋‚˜ ๊ทธ ์‚ฌ๋žŒ์˜ ํ–‰์šด์˜ ์ˆ˜๋ฅผ ์ฐพ์•„ ๋ณผ ์ˆ˜ ์žˆ์ง€.

์ด์ œ `getNum` ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ์ด ์ปจํŠธ๋ ‰ํŠธ์— ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ๊ณ ์ž ํ•˜๋Š” external ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•ด ๋ณด์„ธ.

๋จผ์ €, `LuckyNumber` ์ปจํŠธ๋ ‰ํŠธ์˜ **_์ธํ„ฐํŽ˜์ด์Šค_**๋ฅผ ์ •์˜ํ•  ํ•„์š”๊ฐ€ ์žˆ๋„ค:

```
contract NumberInterface {
function getNum(address _myAddress) public view returns (uint);
}
```

์•ฝ๊ฐ„ ๋‹ค๋ฅด์ง€๋งŒ, ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒƒ์ด ์ปจํŠธ๋ ‰ํŠธ๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒƒ๊ณผ ์œ ์‚ฌํ•˜๋‹ค๋Š” ๊ฑธ ์ฐธ๊ณ ํ•˜๊ฒŒ. ๋จผ์ €, ๋‹ค๋ฅธ ์ปจํŠธ๋ ‰ํŠธ์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ํ•จ์ˆ˜๋งŒ์„ ์„ ์–ธํ•  ๋ฟ(์ด ๊ฒฝ์šฐ, `getNum`์ด ๋ฐ”๋กœ ๊ทธ๋Ÿฌํ•œ ํ•จ์ˆ˜์ด์ง€) ๋‹ค๋ฅธ ํ•จ์ˆ˜๋‚˜ ์ƒํƒœ ๋ณ€์ˆ˜๋ฅผ ์–ธ๊ธ‰ํ•˜์ง€ ์•Š๋„ค. .

๋‹ค์Œ์œผ๋กœ, ํ•จ์ˆ˜ ๋ชธ์ฒด๋ฅผ ์ •์˜ํ•˜์ง€ ์•Š์ง€. ์ค‘๊ด„ํ˜ธ `{`, `}`๋ฅผ ์“ฐ์ง€ ์•Š๊ณ  ํ•จ์ˆ˜ ์„ ์–ธ์„ ์„ธ๋ฏธ์ฝœ๋ก (`;`)์œผ๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋๋‚ด์ง€.

๊ทธ๋Ÿฌ๋‹ˆ ์ธํ„ฐํŽ˜์ด์Šค๋Š” ์ปจํŠธ๋ ‰ํŠธ ๋ผˆ๋Œ€์ฒ˜๋Ÿผ ๋ณด์ธ๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ์ง€. ์ปดํŒŒ์ผ๋Ÿฌ๋„ ๊ทธ๋ ‡๊ฒŒ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ธ์‹ํ•˜์ง€.

์šฐ๋ฆฌ์˜ ๋Œ‘ ์ฝ”๋“œ์— ์ด๋Ÿฐ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํฌํ•จํ•˜๋ฉด ์ปจํŠธ๋ ‰ํŠธ๋Š” ๋‹ค๋ฅธ ์ปจํŠธ๋ ‰ํŠธ์— ์ •์˜๋œ ํ•จ์ˆ˜์˜ ํŠน์„ฑ, ํ˜ธ์ถœ ๋ฐฉ๋ฒ•, ์˜ˆ์ƒ๋˜๋Š” ์‘๋‹ต ๋‚ด์šฉ์— ๋Œ€ํ•ด ์•Œ ์ˆ˜ ์žˆ๊ฒŒ ๋˜์ง€.

๋‹ค์Œ ๋ ˆ์Šจ์—์„œ ๋‹ค๋ฅธ ์ปจํŠธ๋ ‰ํŠธ์˜ ํ•จ์ˆ˜๋ฅผ ์‹ค์ œ๋กœ ํ˜ธ์ถœํ•  ๊ฒƒ์ผ์„ธ. ์ง€๊ธˆ์€ ํฌ๋ฆฝํ† ํ‚คํ‹ฐ ์ปจํŠธ๋ ‰ํŠธ๋ฅผ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์„ ์–ธํ•ด ๋ณด์„ธ.

# ์ง์ ‘ ํ•ด๋ณด๊ธฐ

์ž๋„ค๋ฅผ ์œ„ํ•ด ํฌ๋ฆฝํ† ํ‚คํ‹ฐ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ฐพ์•„ ๋ดค๋„ค. ๊ฑฐ๊ธฐ์„œ, (์šฐ๋ฆฌ ์ข€๋น„ ๊ฒŒ์ž„์—์„œ ์ƒˆ๋กœ์šด ์ข€๋น„๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ!) "์œ ์ „์ž"๋ฅผ ํฌํ•จํ•œ ๋ชจ๋“  ํ‚คํ‹ฐ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” `getKitty`๋ผ๋Š” ํ•จ์ˆ˜๋ฅผ ๋ฐœ๊ฒฌํ–ˆ๋„ค.

`getKitty` ํ•จ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋„ค:

```
function getKitty(uint256 _id) external view returns (
bool isGestating,
bool isReady,
uint256 cooldownIndex,
uint256 nextActionAt,
uint256 siringWithId,
uint256 birthTime,
uint256 matronId,
uint256 sireId,
uint256 generation,
uint256 genes
) {
Kitty storage kit = kitties[_id];
// if this variable is 0 then it's not gestating
isGestating = (kit.siringWithId != 0);
isReady = (kit.cooldownEndBlock <= block.number);
cooldownIndex = uint256(kit.cooldownIndex);
nextActionAt = uint256(kit.cooldownEndBlock);
siringWithId = uint256(kit.siringWithId);
birthTime = uint256(kit.birthTime);
matronId = uint256(kit.matronId);
sireId = uint256(kit.sireId);
generation = uint256(kit.generation);
genes = kit.genes;
}
```

์ด ํ•จ์ˆ˜๋Š” ์šฐ๋ฆฌ์—๊ฒŒ ์ต์ˆ™ํ•œ ํ•จ์ˆ˜๋“ค๊ณผ๋Š” ๋‹ฌ๋ผ ๋ณด์ด์ง€. ํ•จ์ˆ˜๊ฐ€ ๋‹ค์–‘ํ•œ ๊ฐ’๋“ค์„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์žˆ์ง€... ์ž๋„ค๊ฐ€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๊ฐ™์€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ์ด์šฉํ•ด ๋ณธ ์ ์ด ์žˆ๋‹ค๋ฉด ์ด ์ ์ด ๋‹ค๋ฅด๋‹ค๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ์„ ๊ฑฐ๋„ค. ์†”๋ฆฌ๋””ํ‹ฐ์—์„œ๋Š” ํ•จ์ˆ˜๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ์˜ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ์ง€.

`getKitty` ํ•จ์ˆ˜๊ฐ€ ์–ด๋–ค ํ•จ์ˆ˜์ธ์ง€ ์•Œ์•„ ๋ณด์•˜์œผ๋‹ˆ, ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“ค์–ด ๋ณผ ์ˆ˜ ์žˆ์„ ๊ฑธ์„ธ:

1. `KittyInterface`๋ผ๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ •์˜ํ•œ๋‹ค. ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜๊ฐ€ `contract` ํ‚ค์›Œ๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ƒˆ๋กœ์šด ์ปจํŠธ๋ ‰ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™๋‹ค๋Š” ์ ์„ ๊ธฐ์–ตํ•  ๊ฒƒ.

2. ์ธํ„ฐํŽ˜์ด์Šค ๋‚ด์— `getKitty` ํ•จ์ˆ˜๋ฅผ ์„ ์–ธํ•œ๋‹ค (์œ„์˜ ํ•จ์ˆ˜์—์„œ ์ค‘๊ด„ํ˜ธ ์•ˆ์˜ ๋ชจ๋“  ๋‚ด์šฉ์€ ์ œ์™ธํ•˜๊ณ  `return` ํ‚ค์›Œ๋“œ ๋ฐ ๋ฐ˜ํ™˜ ๊ฐ’ ์ข…๋ฅ˜๊นŒ์ง€๋งŒ ๋ณต์‚ฌ/๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•˜๊ณ  ๊ทธ ๋‹ค์Œ์— ์„ธ๋ฏธ์ฝœ๋ก ์„ ๋„ฃ์–ด์•ผ ํ•œ๋‹ค).
Loading

0 comments on commit ce0a3ce

Please sign in to comment.