-
31. How To Code Along In These Sections - Remix Ethereum IDE Introduction
-
-
33. What Is Solidity (As A Coding Language)
-
-
34. Pragma Solidity (How To Select Compiler Versions)
-
-
35. Creating Smart Contracts In Solidity
-
-
36. What are Variables & Datatypes in Solidity
-
-
37. Deploying Your Very First Smart Contract Token
-
38. Visibility keywords in Solidity
-
39. Exercise - Solidity Visibility Challenge
-
-
40. Solution
드디어..! solidity를 배운다..!
31. How To Code Along In These Sections - Remix Ethereum IDE Introduction
"remix.ethereum.org" 를 주소창에 입력하면 Remix IDE에 접속할 수 있다.
여기서 실습을 진행한다. Compiler 탭에서 language는 Solidity를 선택하고(default 설정이다.) DEPLOY&RUN TRANSACTIONS 탭에서는 Environment를 JavaScript VM으로 선택한다. Injected Web3는 선택하면 안된다고 한다.
그리고 Crypto-Token-Contract.sol 이라는 파일을 새로 생성하면 준비 끝!
IDE: REMIX ETHEREUM stands for Interactive Development Environment
33. What Is Solidity (As A Coding Language)
Solidity programming is the primary code language currently used for implementing smart contracts.
Developed on the Ethereum platform, Solidity allows programmers to write smart contracts and blockchain dApps. (물론 Binance나 다른 곳에서도 사용 가능하다.) Javascript와 C++의 영향을 많이 받은 언어라고 한다.
34. Pragma Solidity (How To Select Compiler Versions)
// pragma solidity defines our compiler version for solidity
pragma solidity ^0.8.4;
// ^ the uptick arrow defines a range compile version after the non zero
// digit upwards to the next increment of the non zero number
^0.8.4는 최소 0.8.4 이상의 버전으로 컴파일 되어야 한다는 것을 의미한다. 하지만 0.9는? 안된다.
compiler 버전마다 syntax도 다르고 지원되는 기능도 다르기 때문에 항상 solidity compiler의 version을 지정해주어야 한다.
35. Creating Smart Contracts In Solidity
// the very first step to write a smart contract
// in solidity everything is explicitly declared
contract CryptoToken {
// all the code to write smart contracts go in here
// objects in programming are an abstract datatype with the ability for inheritance
}
Solidity is Object-oriented language
모든 smart contract는 contract (contract 이름) {} 으로 이루어져 있다. {} 안에 contract의 내용이 들어가고, contract는 object라고 생각하면 된다.
36. What are Variables & Datatypes in Solidity
uint public tokens = 400;
CryptoToken contract에서 우리의 미션은 to mint tokens 이다.
그러기 위해 먼저 우리는 integer를 저장하는 datatype이 필요한데, uint(unassigned integer) 타입의 변수를 사용한다. 또한 solidity에서는 expression이 끝날 때 세미콜론 ; 을 붙여주는 것을 잊지 말도록 하자.
37. Deploying Your Very First Smart Contract Token
이제 다시 COMPILER 탭으로 가서 Compile Crypto-Token-Contract.sol 버튼을 클릭하면 우리가 작성한 smart contract 코드가 컴파일 된다. (lisense warning은 무시해도 된다.)
그리고 DEPLOY 탭으로 넘어가면 DEPLOY 버튼이 활성화되어 있을 것이다. DEPLOY를 클릭하고, Deployed Contracts를 누르면 우리가 작성한 코드가 Deploy된 것을 확인할 수 있고 tokens라는 버튼도 활성화되어 있을 것이다. tokens 버튼을 누르면 0:uint256: 400 이라고 뜨는데 이는 위에서 우리가 tokens라는 uint 타입 변수에 400을 할당했기 때문이다.
console창을 확인하면 초록색 체크표시와 함께 deploy 정보를 확인할 수 있는데 Debug 옆에 있는 화살표를 누르면 해시 정보를 포함한 자세한 정보를 볼 수 있다. 이때 transaction cost도 표시가 되어 있는데, 실제로 account를 확인하면 처음엔 100ETH 였던 것이 조금 줄어든 것을 확인할 수 있을 것이다.
38. Visibility keywords in Solidity
// we only want the msg.sender (the current caller)
// to be able to mint tokens
address public minter;
address를 저장하는 변수를 minter라는 이름으로 선언한다.
그리고 앞서 만들었던 tokens 변수를 private으로 바꾼 후, 다시 Deploy를 진행하면, Deployed contracts 탭에서 minter는 보이지만 tokens는 사라진 것을 확인할 수 있다. public, private, external, internal은 이처럼 Visibility와 관련되어 있는데, private이나 internal로 선언한 경우에는 외부에서 접근을 할 수 없다. external로 선언하면 에러가 발생한다.
39. Exercise - Solidity Visibility Challenge
Excercise:
- create a var integer called totalSupply and set it to 7
- totalSupply should not be accessible outside of the smart contract
- create a var address called sender and set it so that it is publically accessible
40. Solution
uint private totalSupply = 7;
address public sender;
간단한 Excercise 였다. 역시 초반이라 그런지 아주아주 간단한 내용만 다루었다.
마치 처음 프로그래밍 배울 때 Hello World 출력하는 느낌이라 후에 뭐가 다가올 지 두렵지만..ㅎㅎ
'스터디📖 > 블록체인' 카테고리의 다른 글
드디어..! solidity를 배운다..!
31. How To Code Along In These Sections - Remix Ethereum IDE Introduction
"remix.ethereum.org" 를 주소창에 입력하면 Remix IDE에 접속할 수 있다.
여기서 실습을 진행한다. Compiler 탭에서 language는 Solidity를 선택하고(default 설정이다.) DEPLOY&RUN TRANSACTIONS 탭에서는 Environment를 JavaScript VM으로 선택한다. Injected Web3는 선택하면 안된다고 한다.
그리고 Crypto-Token-Contract.sol 이라는 파일을 새로 생성하면 준비 끝!
IDE: REMIX ETHEREUM stands for Interactive Development Environment
33. What Is Solidity (As A Coding Language)
Solidity programming is the primary code language currently used for implementing smart contracts.
Developed on the Ethereum platform, Solidity allows programmers to write smart contracts and blockchain dApps. (물론 Binance나 다른 곳에서도 사용 가능하다.) Javascript와 C++의 영향을 많이 받은 언어라고 한다.
34. Pragma Solidity (How To Select Compiler Versions)
// pragma solidity defines our compiler version for solidity
pragma solidity ^0.8.4;
// ^ the uptick arrow defines a range compile version after the non zero
// digit upwards to the next increment of the non zero number
^0.8.4는 최소 0.8.4 이상의 버전으로 컴파일 되어야 한다는 것을 의미한다. 하지만 0.9는? 안된다.
compiler 버전마다 syntax도 다르고 지원되는 기능도 다르기 때문에 항상 solidity compiler의 version을 지정해주어야 한다.
35. Creating Smart Contracts In Solidity
// the very first step to write a smart contract
// in solidity everything is explicitly declared
contract CryptoToken {
// all the code to write smart contracts go in here
// objects in programming are an abstract datatype with the ability for inheritance
}
Solidity is Object-oriented language
모든 smart contract는 contract (contract 이름) {} 으로 이루어져 있다. {} 안에 contract의 내용이 들어가고, contract는 object라고 생각하면 된다.
36. What are Variables & Datatypes in Solidity
uint public tokens = 400;
CryptoToken contract에서 우리의 미션은 to mint tokens 이다.
그러기 위해 먼저 우리는 integer를 저장하는 datatype이 필요한데, uint(unassigned integer) 타입의 변수를 사용한다. 또한 solidity에서는 expression이 끝날 때 세미콜론 ; 을 붙여주는 것을 잊지 말도록 하자.
37. Deploying Your Very First Smart Contract Token
이제 다시 COMPILER 탭으로 가서 Compile Crypto-Token-Contract.sol 버튼을 클릭하면 우리가 작성한 smart contract 코드가 컴파일 된다. (lisense warning은 무시해도 된다.)
그리고 DEPLOY 탭으로 넘어가면 DEPLOY 버튼이 활성화되어 있을 것이다. DEPLOY를 클릭하고, Deployed Contracts를 누르면 우리가 작성한 코드가 Deploy된 것을 확인할 수 있고 tokens라는 버튼도 활성화되어 있을 것이다. tokens 버튼을 누르면 0:uint256: 400 이라고 뜨는데 이는 위에서 우리가 tokens라는 uint 타입 변수에 400을 할당했기 때문이다.
console창을 확인하면 초록색 체크표시와 함께 deploy 정보를 확인할 수 있는데 Debug 옆에 있는 화살표를 누르면 해시 정보를 포함한 자세한 정보를 볼 수 있다. 이때 transaction cost도 표시가 되어 있는데, 실제로 account를 확인하면 처음엔 100ETH 였던 것이 조금 줄어든 것을 확인할 수 있을 것이다.
38. Visibility keywords in Solidity
// we only want the msg.sender (the current caller)
// to be able to mint tokens
address public minter;
address를 저장하는 변수를 minter라는 이름으로 선언한다.
그리고 앞서 만들었던 tokens 변수를 private으로 바꾼 후, 다시 Deploy를 진행하면, Deployed contracts 탭에서 minter는 보이지만 tokens는 사라진 것을 확인할 수 있다. public, private, external, internal은 이처럼 Visibility와 관련되어 있는데, private이나 internal로 선언한 경우에는 외부에서 접근을 할 수 없다. external로 선언하면 에러가 발생한다.
39. Exercise - Solidity Visibility Challenge
Excercise:
- create a var integer called totalSupply and set it to 7
- totalSupply should not be accessible outside of the smart contract
- create a var address called sender and set it so that it is publically accessible
40. Solution
uint private totalSupply = 7;
address public sender;
간단한 Excercise 였다. 역시 초반이라 그런지 아주아주 간단한 내용만 다루었다.
마치 처음 프로그래밍 배울 때 Hello World 출력하는 느낌이라 후에 뭐가 다가올 지 두렵지만..ㅎㅎ