記事一覧
【CryptoZombies】lesson1 chapter15
lesson1完結。
学んだこと
・イーサリアムのスマートコントラクトの書き方
・solidityのプログラミング、イーサリアムスマートコントラクトのプログラム言語
・イーサリアム上でゲーム開発
感想
・単純に面白い
・が、結構つまづく箇所も多く難しく感じた(慣れるしかなさそう)
→基本的にはプログラミングは覚える必要なし。調べながらコードを書くので、なんとなくの流れを掴めばOKかな。
さて
【CryptoZombies】lesson1 Chapter 14: Web3.js
Ethereum has a Javascript library called Web3.js.
このチャプターでは、名前を入力しどんなゾンビになるのかを確認する回。
沢山コードが出てくるが、現時点では全く理解できなくてOK。
【CryptoZombies】lesson1 Chapter 13: Events
Events are a way for your contract to communicate that something happened on the blockchain to your app front-end, which can be 'listening' for certain events and take action when they happen.
Exampl
【CryptoZombies】lesson1 Chapter 12: Putting It Together
test
1.Create a public function named createRandomZombie. It will take one parameter named _name (a string with the data location set to memory). (Note: Declare this function public just as you decla
【CryptoZombies】lesson1 Chapter 11: Keccak256 and Typecasting
Ethereum has the hash function keccak256 built in, which is a version of SHA3. A hash function basically maps an input into a random 256-bit hexadecimal number. A slight change in the input will cause
もっとみる【CryptoZombies】lesson1 Chapter 10: More on Functions
Return Values
To return a value from a function, the declaration looks like this:
string greeting = "What's up dog";function sayHello() public returns (string memory) { return greeting;}
In Solidit
【CryptoZombies】lesson1 Chapter 9: Private / Public Functions
In Solidity, functions are public by default. This means anyone (or any other contract) can call your contract's function and execute its code.
it's good practice to mark your functions as private by
【CryptoZombies】lesson1 Chapter 8: Working With Structs and Arrays
struct Person { uint age; string name;}Person[] public people;
Now we're going to learn how to create new Persons and add them to our people array.
// create a New Person:Person satoshi = Person(172
【CryptoZombies】lesson1 Chapter 7: Function Declarations
A function declaration in solidity looks like the following:
function eatHamburgers(string memory _name, uint _amount) public {}
This is a function named eatHamburgers that takes 2 parameters: a str
【CryptoZombies】lesson1 Chapter 6: Arrays
// Array with a fixed length of 2 elements:uint[2] fixedArray;// another fixed Array, can contain 5 strings:string[5] stringArray;// a dynamic Array - has no fixed size, can keep growing:uint[] dynami
もっとみる【CryptoZombies】lesson1 Chapter 5: Structs
Yes:struct
No:stract
test
pragma solidity >=0.5.0 <0.6.0;contract ZombieFactory { uint dnaDigits = 16; uint dnaModulus = 10 ** dnaDigits; // start here struct Zombie { string name;
【CryptoZombies】lesson1 Chapter 4: Math Operations
・Addition: x + y
・Subtraction: x - y,
・Multiplication: x * y
・Division: x / y
・Modulus / remainder: x % y (for example, 13 % 5 is 3, because if you divide 5 into 13, 3 is the remainder)
Solidity also
【CryptoZombies】lesson1 Chapter 3: State Variables & Integers
The uint data type is an unsigned integer, meaning its value must be non-negative. There's also an int data type for signed integers.
In Solidity, uint is actually an alias for uint256, a 256-bit uns
【CryptoZombies】lesson1 Chapter 2: Contracts
Solidity's code is encapsulated in contracts.
An empty contract named HelloWorld would look like this.
contract HelloWorld {}
All solidity source code should start with a "version pragma".
pragma