Solidity

[CryptoZombie] 1-4 Zombie Battle System

🧑 Payable

이더리움을 μ§€λΆˆμ— κ΄€μ—¬ν•  수 μžˆλŠ” ν•¨μˆ˜ μ œμ–΄μžμ΄λ‹€.

contract OnlineStore {
  function buySomething() external payable {    
    require(msg.value == 0.001 ether);    
    transferThing(msg.sender);
  }
}

 

🧑 Random Numbers

keccak256을 μ΄μš©ν•΄ λ‚œμˆ˜λ₯Ό 생성할 수 μžˆλ‹€.

uint randNonce = 0;
uint random = uint(keccak256(now, msg.sender, randNonce)) % 100;
randNonce++;
uint random2 = uint(keccak256(now, msg.sender, randNonce)) % 100;

 

https://share.cryptozombies.io/ko/lesson/4/share/bjloed?id=WyJjenwxMjAyMjMiLDEsMTRd