ICT role in 21st century education and its challenges
About dapp
1. dApp 개발
September, 13th 2018
SGBL Extra Session
Sogang Blockchain Lab.
Image copyright to salientcrgt.com
2. Truffle3
• Smart contract 소스 코드의 컴파일, linking, 그리고 Ethereum 네트워크에 배포를 관리하는 프레임워크
다.
web3.js1
dApp Developent
web3.js 과 truffle이란?
September 13th, 2018 Extra Forum Page 2
설명 topic
• web3.js 는 로컬 혹은 외부 Ethereum 노드와 JSON-RPC를 통해 통신하는 Ethereum compatible한
Javascript API를 말한다.
• web3.js 는 ABI(Application Binary Interface)를 통해서 EVM과 통신한다.
3. dApp Developent
dApp 구조
September 13th, 2018 Extra Forum Page 3
설명 topic
출처: 이더리움 연구회 정기 발표회 세션5-web3.js와 Nodejs를 사용한 dApp 개발
dApp
Smart Contract
Frontend
web3.js
Backend
web3.js
JSON RPC
EVM
Ethereum
Blockchain
ABI
4. dApp Developent
dApp 구조
September 13th, 2018 Extra Forum Page 4
설명 topic
출처: 이더리움 연구회 정기 발표회 세션5-web3.js와 Nodejs를 사용한 dApp 개발
dApp
Smart Contract
Frontend
web3.js
Backend
web3.js
JSON RPC
EVM
Ethereum
Blockchain
ABI
5. dApp Developent
API 설명
June 26th, 2018 _ 1st sess Page 5
web3.eth.sendTransaction(trasnsactionObject [, callback])1
• 네트워크에 transaction을 보내는 web3 API
• trasnsactionObject 는 생성할 transaction의 속성을 정의한 object로, from, to, value, gasPrice,
data, nonce 가 포함된다.
• [, callback] 은 callback 함수로, sendTransaction 을 호출하고 받는 response를 정의한 함수로,
transaction ID를 반환 받는다.
6. dApp Developent
API 설명
June 26th, 2018 _ 1st sess Page 6
web3.eth.sendTransaction(trasnsactionObject [, callback])1
7. dApp Developent
API 설명
June 26th, 2018 _ 1st sess Page 7
web3.eth.sendTransaction(trasnsactionObject [, callback])1
transaction object
callback function
• 예시 코드)
8. dApp Developent
API 설명
June 26th, 2018 _ 1st sess Page 8
web3.eth.getTransaction(trasnsactionHash [, callback])2
• 인자로 넘긴 transactionHash를 갖는 transaction이 새 블록에 포함되면, transaction 정보를 반환하는
함수로, 블록에 포함되어있지 않은 경우에 null을 반환한다.
• 주로 블록체인 상의 변화를 체크하는 함수인 web3.eth.filter와 함께 쓰인다.
9. dApp Developent
API 설명
June 26th, 2018 _ 1st sess Page 9
web3.eth.getTransaction(trasnsactionHash [, callback])2
• 예시 코드)
10. dApp Developent
API 설명
June 26th, 2018 _ 1st sess Page 10
web3.eth.getTransactionReceipt(hashString [, callback])3
• Contract에서 발생한 결과를 receipt의 형태로 반환 받는 함수로, transaction의 hash를 인자로 호출한다.
• receipt는 transaction의 결과를 기록한 로그로, Solidity의 event 함수 호출로 기록이 가능하다.
11. dApp Developent
API 설명
June 26th, 2018 _ 1st Forum Page 11
Receipt
Sunset message: abcdcfg …………………………………………………
Solidity
Event 호출 Receipt 결과