無知

갈 길이 먼 공부 일기

솔리디티 5

스마트 컨트랙트 (5-7) | Solidity(솔리디티) 라이브러리, Libraries

1. Libraries - 솔리디티에서 라이브러리는 한번 설치되어 여러 다른 contract들에 의해서 사용. - 따라서, 동일한 코드가 반복해서 이더리움 네트워크에 설치되는 것을 방지. - 라이브러리 함수는 contract 메소드 호출과 유사하다 - 라이브러리는 자신의 storage를 갖지 못한다 - 라이브러리는 이더를 소유할 수 없다 - 라이브러리는 state variable을 가질 수 없다 - 라이브러리는 상속 관계에 있을 수 없다 - 라이브러리는 fallback 함수를 가질 수 없다 - 라이브러리는 payable 함수를 가질 수 없다 pragma solidity >=0.4.0 =0.6.0 bool) flags; } library Set { // Note that the first parameter..

스마트 컨트랙트 (5-6) | Solidity(솔리디티) Error Handling

Error handling require revert assert Use when control flow is simple control flow is complicated control flow is simple Check Pre-condition Pre-condition Post-condition Returns Gas Unused Return Return Does not Return - 솔리디티에서는 exception 발생 시 현재까지의 모든 transaction이 중단되고 transaction 이전 상태로 돌아간다. exception을 발생시키기 위한 함수 1. require 주어진 조건을 검사해서 이를 만족시키지 못하면 exception을 발생시킨다. 남은 gas는 반환된다. // require(..

스마트 컨트랙트 (5-5) | Solidity(솔리디티) Contracts, Inheritance, Interface

1. Contract Contracts can be created “from outside” via Ethereum transactions or from within Solidity contracts. IDEs, such as Remix, make the creation process seamless using UI elements. One way to create contracts programmatically on Ethereum is via the JavaScript API web3.js. It has a function called web3.eth.Contract to facilitate contract creation. When a contract is created, its constructo..

스마트 컨트랙트 (5-2) | Solidity(솔리디티) State Variable, Type

3. Contents 3-1. Contract 3-1-1. Variable 3-1-1-1. State Variable State Variable은 EVM 내 스토리지에 저장된다. 메모리에 저장되는 임시 값들과 반대된다. 스토리지는 컨트랙트의 모든 함수가 접근할 수 있다. 즉, EVM의 storage 영역은 contract 내의 모든 function 이 접근할 수 있으며 function이 변경한 값은 계속해서 저장되어 다음 번 function에서 저장된 값을 사용할 수 있다. 컨트랙트의 함수 바깥에서 선언되었다. State Variables State variables are variables whose values are permanently stored in contract storage. See th..

스마트 컨트랙트 (5-1) | Solidity(솔리디티) 레이아웃

1. Solidity Language 1-1. 특성 - 절차적 언어 ( VS 함수형 언어) - 정적 타입 언어 (컴파일 시 타입 결정. 오류 시 컴파일 에러) - 변수 이름의 대소문자 구분 - 객체 지향 언어 - 확장자 : sol 2. LayOut 2-1. pragma 파일 최상단에 위치, 컴파일러의 특정 기능을 활성화하는 데에 사용 Pragmas The pragma keyword is used to enable certain compiler features or checks. A pragma directive is always local to a source file, so you have to add the pragma to all your files if you want to enable it in..