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;
답변 1
truffle project 세팅관련
0
302
1
gas 계산하는 부분이 이해가 되지 않습니다.
0
324
1
Lottery Bet 함수 테스트 강의 중 4:36에서 'from' 관련 오류가 발생합니다.
1
597
3
폴더 안에 파일이 없습니다.
0
343
0
address payable error
0
361
1
migrations 내의 js파일에서 artifacts 객체를 불러올 수 없습니다
1
320
0
안녕하세요 강의 잘 따라와서 끝까지 잘 해냈습니다!!
0
223
0
안녕하세요 강의 정말 잘듣고있습니다.
1
489
1
안녕하세요. Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
1
252
0
setState 사용에 대해서 질문입니다.
0
303
1
bootstrap library 설치 error
0
300
0
web3.eth.sendTransaction()
0
367
0
잘 쫓아가고 있습니다만 왜 저는 빨간선이 나올까요?
0
266
0
React js 환경설정 강의 질문
0
287
1
web3오류
0
380
2
코드 원본을 받을 수 있을까요?
0
352
2
ganache-cli 명령어 질문
0
351
1
Gas 부족 에 대한 질문입니다.
0
301
2
geth 채굴시 unlock 이외의 방법이 있을까요?
0
294
2
테스트 코드 작성 중 오류가 발생합니다.
0
315
2
truffle migrate
0
274
1
질문입니다
0
303
2
8:22 에러
0
288
2
콘솔창에서 에러..
0
1048
5





