무료
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
truffle project 세팅관련
안녕하세요!갑자기 걱정이 되는게이거 세팅하고 테스트한다고 해서 돈이 나가고 그런건 아닌거죠..?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
gas 계산하는 부분이 이해가 되지 않습니다.
이더리움 GAS 계산 강의에서, Truffle console로 bet 함수의 가스비를 계산해보았습니다. 첫번째 실행과 두번째 실행시의 가스비가 15000 정도 차이가 나는데, 그 이유가 첫번째 실행에서는 tail 변수를 초기화해야해서 20000 gas가 소모되고 두번째 실행에서는 _tail 변수의 값만 업데이트하기 때문에 5000 gas가 소모되기 때문이라고 하셨습니다. 그런데 본 컨트렉트 코드에서는 tail을 초기화해주는 코드는 보이지 않고 오로지 _tail++; 코드만 존재하는데, 첫번째 실행에서도 업데이트를 해주는 것 아닐까요? 강사님의 답변을 기다리겠습니다!
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
Lottery Bet 함수 테스트 강의 중 4:36에서 'from' 관련 오류가 발생합니다.
감사하게도 강좌를 통해 스마트 컨트랙트에 대해서 배우고 있는데요, Bet 테스트 코드 실행 시, 에러가 발생하고 있는데 어디서 문제인지 파악이 안되서 질문글 올려요 Error: The send transactions "from" field must be defined! Lottery.solpragma solidity >=0.4.22 <0.9.0; contract Lottery { struct BetInfo { uint256 answerBlockNumber; address payable bettor; byte challenges; //0xab... } address public owner; uint256 private _tail; uint256 private _head; mapping (uint256 => BetInfo) private _bets; uint256 private _pot; uint256 constant internal BET_AMOUNT = 5 * 10 ** 15; uint256 constant internal BET_BLOCK_INTERVAL = 3; uint256 constant internal BLOCK_LIMIT = 256; event BET(uint256 index, address bettor, uint256 amount, byte challenges, uint256 answerBlockNumber); constructor() public { owner = msg.sender; } function getPot() public view returns (uint256 pot) { return _pot; } /** * @dev 베팅을 한다. 유저는 0.005 ETH를 보내야 하고, 베팅을 1 byte 글자를 보낸다. * 큐에 저장된 베팅 정보는 이후 distribute 함수에서 해결된다. * @param challenges 유저가 베팅하는 글자 * @return 함수가 잘 수행되었는지 확인히는 bool 값 */ function bet(byte challenges) public payable returns (bool result) { // check the paater ether is sent require(msg.value == BET_AMOUNT, "Not enoughf ETH"); // push bet to the queue require(pushBet(challenges), "Fail to add a new Bet Info"); // emit evnet emit BET(_tail - 1, msg.sender, msg.value, challenges, block.number + BET_BLOCK_INTERVAL); return true; } // save ther bet to the queue // 결과값 검증 // check the answer function getBetInfo(uint256 index) public view returns (uint256 answerBlockNumber, address bettor, byte challenges) { BetInfo memory b = _bets[index]; answerBlockNumber = b.answerBlockNumber; bettor = b.bettor; challenges = b.challenges; } // function pushBet(byte challenges) public returns (bool) { function pushBet(byte challenges) internal returns (bool) { BetInfo memory b; b.bettor = msg.sender; b.answerBlockNumber = block.number + BET_BLOCK_INTERVAL; b.challenges = challenges; _bets[_tail] = b; _tail++; return true; } // function popBet(uint256 index) public returns (bool) { function popBet(uint256 index) internal returns (bool) { delete _bets[index]; return true; } } lottery.test.js const assertRevert = require("./assertRevert"); const Lottery = artifacts.require("Lottery"); contract('Lottery', function (deployer, user1, user2) { let lottery; beforeEach(async () => { lottery = await Lottery.new(); }) //it.only('getPot should return current pot', async () => { it('getPot should return current pot', async () => { let pot = await lottery.getPot(); assert.equal(pot, 0); }) describe('Bet', function () { console.log(user1); it.only('should fail when the bet money is not 0.005 ETH', async () => { // Fail transaction await assertRevert(lottery.bet('0xab', { from: user1, value: 4000000000000000 })) // transaction object {chainId, value, to, from, gas, gasPrice} }) it('should put the bet to the bet queue with 1 bet', async () => { // bet await lottery.bet('0xab', { from: user1, value: 5000000000000000 }) // check contract balance == 0.005 // check bet info // check log }) }) }); 중간에 제가 노트북을 리부트해서 서버의 정보가 날라가서 일까요?? ganache-cli -d -m tutorial로 다시 구동했는데, user1를 출력해보면 undefined가 나옵니다. ㅠㅠ
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
폴더 안에 파일이 없습니다.
정상적으로 진행하고 VScode를 열었는데,contracts 폴더 안에 Migrations.sol이라는 파일 대신 .gitkeep이라는 빈 파일과migrations 폴더 안에 1_initial_migration.js 파일 대신 .gitkeep이라는 빈 파일이 들어있습니다.이 때는 어떻게 해결해야 될까요?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
address payable error
I am getting the error in solidity 0.8.7
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
migrations 내의 js파일에서 artifacts 객체를 불러올 수 없습니다
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. const Lottery = artifacts.require("Lottery"); 에서 artifacts 객체를 선언할 수 없다는 메세지가 뜹니다. build폴더에 있는 Lottery.json파일에서 데이터를 가져오는 것으로 강의에서 설명이 되어있는데 ide에서는 import가 되지 않는 것으로 나와서 문의드립니다
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
안녕하세요 강의 잘 따라와서 끝까지 잘 해냈습니다!!
우선 좋은 강의 덕분에 첫 솔리디티 리엑트 작품을 만들었네요!! 정말 감사드립니다!! 저는 리엑트 훅스로 따라했는데 History table이 안나올때도 있고 나왔었는데 setInterval로 2초씩 줬는데 나왔다가 리렌더링 되고 안나왔다가 다시 나왔다가 계속 반복되고있는데 어떤게 문제일까요.. useCallback으로 감싸줬고 리렌더링 처리 잘 해줬다고 생각했는데 잘 안되네여 ㅜㅜ
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
안녕하세요 강의 정말 잘듣고있습니다.
잘 따라오고 있다가 오늘 이벤트가 발생하지 않은 오류가 나왔습니다. Contract: Lottery isMatch 1) should be BettingResult.Win when two characters match > No events were emitted 2) should be BettingResult.Fail when two characters match > No events were emitted 3) should be BettingResult.Draw when two characters match > No events were emitted 0 passing (229ms) 3 failing 1) Contract: Lottery isMatch should be BettingResult.Win when two characters match: AssertionError: expected <BN: 0> to equal 1 at Context.<anonymous> (test/Lottery.test.js:60:14) at processTicksAndRejections (node:internal/process/task_queues:96:5) 2) Contract: Lottery isMatch should be BettingResult.Fail when two characters match: AssertionError: expected <BN: 2> to equal 0 at Context.<anonymous> (test/Lottery.test.js:65:14) at processTicksAndRejections (node:internal/process/task_queues:96:5) 3) Contract: Lottery isMatch should be BettingResult.Draw when two characters match: AssertionError: expected <BN: 0> to equal 2 at Context.<anonymous> (test/Lottery.test.js:70:14) at processTicksAndRejections (node:internal/process/task_queues:96:5) 무슨 문제인지 찾을수가 없네요 ㅠㅠ
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
안녕하세요. Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
안녕하세요 강사님. 질문드릴게 있어요 ㅜ. Lottery.sol을 만들고 생성자 입력시 constructor() public 부분에 밑줄이 나오고 해당 문제가 보여지는데 이거 문제 없는 건가요? Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient. 그리고 Migrations.sol 파일에 modifier restricted() { require( msg.sender == owner, "This function is restricted to the contract's owner" ); _; } 처럼 선생님과 다르게 나오네요 ㅜ 마지막으로 이 2가지 때문인지는 모르지만 Lottery.sol을 다 입력 후 truffle migrate --reset 입력하면 사용된 가스량이 강의처럼 변경 되어야 하는데. 처음 truffle 실행할 때와 동일한데 무슨 문제일까요? ㅜ 감사합니다.
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
setState 사용에 대해서 질문입니다.
에제 진행할때 클래스형 컴포넌트가 아니라 함수형 컴포넌트로 실습 진행하고 있는데 finalRecords 정의할때 getBetEvent 함수에서 setState 처리한 betRecords 변수에 대해서 저장하는...const recrods = [...this.state.betRecords] 라는 로직에서 계속 널값을 가져와서요.. setState 처리한 변수를 같은 componentDidMount 사이클에서 변수 호출시에 값을 못가져오는게 맞지 않나요?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
bootstrap library 설치 error
수업 구간: 섹션3 Lottery UI 마크업(처음부터) 제가 수업을 들으면서 먼저 실행해보고 코드를 분석해보는 식으로 공부하고 있었습니다. 제가 react web을 올리고 난 후에 yarn add bootstrap을 하면 사진과 같은 에러가 계속 나네요 인터넷에 찾아모니 모듈과 package-lock.json을 삭제하고 npm install하면 된다고 해서 했는데 그러면 yarn start로 웹서버창이 켜지지 않았습니다. 제가 의심스러운 것은 yarn 버전이 강의에서 쓰시던 버전과 달라서 그런건지 궁금합니다. 어떻게 해야 웹서버창도 켜고 yarn add bootstarp도 성공해서 웹 UI를 볼 수 있을까요?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
web3.eth.sendTransaction()
안녕하세요 강사님. localhost:8545에 연결되어 있는것을 확인한 후 truffle console에서 account들을 확인해보았습니다. 그 후 web3.eth.sendTransaction({from:'0xfe51F520Ed5C41467Fd44d359fFEB090efD46C2b', to:'0x26473574354aC02ecB9541CE8E52d8469CdaD9d8', value:10000000000000000000})을 통하여 10eth를 보내고 싶었는데 여전히 첫번째 사진과 같이 0eth로 표시되어있어 어떤 문제때문에 10eth가 전송이 안되는지 모르겠습니다. 위 명령어의 결과는 아래와 같습니다.
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
잘 쫓아가고 있습니다만 왜 저는 빨간선이 나올까요?
아직 초반부 이지만 잘 쫓아 가고 있습니다. ganashe-cli 를 cmd 에서 켜놔야 네트워크 연결이 된다는 곳을 모르고 한참을 헤맸습니다 ^^;;; 위의 이미지들을 보면 저는 왜 빨간선으로 오류 표시가 나올까요??? 실행시키는데 현재까지는 문제가 없긴 한데... 빨간선은 뭔가 문제가 있다는 거 아닌가요?
- Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
리액트 메타마스크 연동관련
삭제된 글입니다
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
React js 환경설정 강의 질문
안녕하세요 React js 환경설정 강의 수강중 문의사항이 있어 질문남깁니다. lottery-react-web 를 생성한 후 App.js 파일을 오픈했을때 강의 영상에서는 클래스형 컴포넌트 형식으로 코드가 작성되어있는데 제 App.js 파일은 함수형 컴포넌트 형식으로 코드가 작성되어있습니다. 혹시 왜 이런 차이가 발생하는지 알려주실수 있으신가요 ?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
web3오류
안녕하세요! 윈도우 환경에서 트러플을활용한 스마트컨트랙트 상호작용 강의 부분을 하다가 막히는 부분이 있어서요ㅠ lt.abi라던가 lt.owner() , getsomevalue()등등 .. 대신 eth.getaccounts()는 작동됩니다! ㅠ
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
코드 원본을 받을 수 있을까요?
안녕하세요. 수업 잘 들었습니다. 그런데 제 코드에서는 문제가 하나 발생합니다. 승자가 나올 경우 팟머니를 가져가는 것 까지는 정상 작동하는데, 이후에 다시 한번 승자가 나올 경우 revert에러가 발생합니다. 이때 팟머니도 변화가 없고 WIN 이벤트도 생성이 안 됩니다. 일단 에러가 나면 이후부터는 동일한 revert에러로 베팅 자체가 안 되고요. 아무리 코드를 살펴봐도 문제를 모르겠더라고요. 그래서 혹시 git이나 메일을 통해 코드 원본을 받을 수 있을까요?
- 미해결Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
ganache-cli 명령어 질문
ganache-cli 실행하실 때 -d -m이 어떤건지 알려주실 수 있나요?? 그리고 tutorial은 그냥 이름을 정해준건가요?
- 해결됨Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
recent mode 질문
안녕하세요 강의 잘 듣고 있습니다. 강의와 같이 소스를 작성했는데, MetaMask 연결 요청이 뜨지 않고, react 로고화면(초기화면)만 나오고 있습니다.recent mode로 접근하지 않는 것 같은데, 무엇이 잘못 되었는지 궁금합니다. 작성한 App.js 같이 남깁니다! import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; import Web3 from 'web3'; class App extends Component{ async componentDidMount() { await this.initWeb3(); } initWeb3 = async() => { if (window.ethereum) { console.log('recent mode'); this.web3 = new Web3(window.ethereum); try { // Request account access if needed await window.ethereum.enable(); // Acccounts now exposed // this.eth.sendTransaction({/* ... */}); } catch (error) { // User denied account access... console.log(`User denied account access error : ${error}`); } } // Legacy dapp browsers... else if (window.web3) { console.log('legacy mode'); this.web3 = new Web3(Web3.currentProvider); // Acccounts always exposed // web3.eth.sendTransaction({/* ... */}); } // Non-dapp browsers... else { console.log('Non-Ethereum browser detected. You should consider trying MetaMask!'); } } render(){ return ( <div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <p> Edit <code>src/App.js</code> and save to reload. </p> <a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer" > Learn React </a> </header> </div> ); } } export default App;
- 해결됨Ethereum 실전! 초보자를 위한 Lottery Dapp 개발
Gas 부족 에 대한 질문입니다.
동영상 강의의 내용을 그대로 따라할 경우 테스트 코드 실행시 항상 Gas 부족 문제가 발생합니다. 현재 동작시키는 스마트 컨트랙트의 Miner 계정의 경우 충분한 양의 Ether 가 있지만 채굴시에는 Gas 부족으로 전체 코드를 한번에 테스트 할 수 없어 현재 it 단위로 끊어서 it.only( ) 로 테스트하고 있습니다. 동영상 강의처럼 문제없이 테스트하려면 어떻게 해야 하는지 (Gas 문제를 해결하는) 방법 부탁 드립니다.