일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- MachineLearning
- xcode
- build
- 맥
- 네트워크
- MAC
- 센토스
- Chrome
- 리눅스
- avds
- ReactNative
- Android
- androidstudio
- node
- centos
- localserver
- qunit
- react
- vsCode
- linux
- picker
- VirtualBox
- PYTHON
- 개발
- jest
- unittest
- TensorFlow
- IOS
- webpack
- Today
- Total
목록Backend/Python & Blockchain (30)
로메오의 블로그
프로젝트 설정 $ python3 --version Python 3.7.4 $ cd /my/project/path $ mkdir facial_recognition $ mkdir facial_recognition/img facial_recognition/img/group $ code ./facial_recognition img/group 폴더에 단체 사진을 넣습니다. 라이브러리 설치 $ pip3 install opencv-python $ pip3 install opencv-contrib-python $ pip3 install cmake $ pip3 install dlib $ pip3 install face_recognition $ pip3 install flask findfaces.py $ touch fin..
App.js에서 truffle과 연결하도록 하겠습니다. /src/js/App.js 계정 정보를 가져와서 Content.js 콤포넌트로 넘겨서 화면에 표시하도록 하겠습니다. import React from 'react' import ReactDOM from 'react-dom' import Web3 from 'web3' import TruffleContract from 'truffle-contract' import Election from '../../build/contracts/Election.json' import Content from './Content' class App extends React.Component { constructor(props) { super(props) this.state ..
/src/index.html react용 root컴포넌트 추가하고 build.js 파일을 불러옵니다. webpack에서 output을 build.js 로 build 합니다. /src/App.js webpack.config.js에서 App.js 파일을 entry로 설정했기 때문에 App.js가 react의 시작이 됩니다. entry: path.join(__dirname, 'src/js', 'App.js'), $ touch src/js/App.js App.js의 기본 구조는 아래와 같습니다. import React from 'react' import ReactDOM from 'react-dom' class App extends React.Component { constructor(props) { super(..
DApp을 만들기 위해서 Solidity로 투표하기 App을 만들었습니다. [DAPP] WATCH EVENT LISTENER 그런데 Front-end 화면 개발을 단순한 html과 jquery를 이용해서 간단하게 구현했었는데요. 이것을 React.js프레임워크를 이용해서 Refactoring 해보겠습니다. 물론 코드를 간단하게 하기 위해서 Bootstrap같은 디자인 적인 요소는 사용하지 않겠습니다. webpack-cli 설치 $ npm install -g webpack-cli webpack-cli 를 글로벌로 설치합니다. React.js 환경 설정 babel 설치 $ npm install --save-dev @babel/core @babel/preset-env @babel/preset-react bab..
마지막으로 Watch Event Listener를 사용해보겠습니다. [DAPP] 투표하기 화면 구현 투표하기에 성공하면 location.reload()로 화면을 강제로 새로고침하였습니다. Election back-end 코드에서 이벤트가 발생했을때 화면으로 이벤트를 전달해 보도록 하겠습니다. /contracts/Election.js pragma solidity ^0.5.0; contract Election { .... // 투표하기 Watch Event event votedEvent ( uint indexed _candidateId ); // 투표하기 function vote(uint _candidateId) public { .... // 이벤트 트리거 emit votedEvent(_candidateId..
우리는 위와 같은 화면을 구현합니다. [DAPP] SOLIDITY FRONT-END ELECTION에서 후보자 읽어오기 위 포스트에 이어서 투표하기 코드를 추가하겠습니다. 먼저 Election.sol 에서 constructor에서 3명의 후보자를 추가하겠습니다. /contracts/Election.sol pragma solidity ^0.5.0; contract Election { .... // constructor constructor() public { addCandidate('romeoh'); addCandidate('doraemong'); addCandidate('pororo'); } .... } constructor에 위와 같이 코드를 추가합니다. 전체 코드는 아래와 같습니다. pragma so..
[DAPP] 투표하기 테스트 코드 작성 위 포스트에 이어 계속 테스트코드를 작성합니다. /test/election.spec.js const Election = artifacts.require('./Election.sol') contract('Election', accounts => { .... it('투표 유효성 검사', () => { return Election.deployed() .then(instance => { electionInstance = instance // 유효하지 않은 후보자에게 투표한다. return electionInstance.vote(99, {from: accounts[0]}) }) .then(assert.fail) .catch(error => { assert(error.mess..
중복투표를 방지하기 위해 vote 메서드에 코드를 추가하겠습니다. /contracts/Election.sol pragma solidity ^0.5.0; contract Election { ... // 투표하기 function vote(uint _candidateId) public { // 중복투표를 하면 오류를 발생 시킨다. require(!voters[msg.sender]); // 목록에 없는 후보자에게 투표하면 오류를 발생시킨다. require(_candidateId > 0 && _candidateId Candidate) public candidates; // 투표에 참여한 ID 기록 mapping(address => bool) public voters; // 후보자 등록하기 function addC..