index.js 질문입니다.
311
작성한 질문수 4
import Web3 from "web3";
import "./app.css";
import ecommerceStoreArtifact from "../../build/contracts/EcommerceStore.json";
var EcommerceStore = contract(ecommerce_store_artifacts);
const App = {
web3: null,
account: null,
start: async function() {
const { web3 } = this;
try {
// get contract instance
const networkId = await web3.eth.net.getId();
const deployedNetwork = ecommerceStoreArtifact.networks[networkId];
this.meta = new web3.eth.Contract(
ecommerceStoreArtifact.abi,
deployedNetwork.address
);
// get accounts
const accounts = await web3.eth.getAccounts();
this.account = accounts[0];
} catch (error) {
console.error("Could not connect to contract or chain.");
}
}
};
window.App = {
start: function() {
var self = this;
//Bootstrap the Metacoin abstraction for use.
EcommerceStore.setProvider(web3.currentProvider);
renderStore();
}
};
function renderStore() {
//get the product count
//loop through and fetch all products by id
var instance;
return EcommerceStore.deployed()
.then(function(f) {
instance = f;
return instance.productIndex.call();
})
.then(function(count) {
for (var i = 1; i <= count; i++) {
renderProduct(instance, i);
}
});
}
function renderProduct(instance, index) {
instance.getProduct.call(index).then(function(f) {
let node = $("<div/>");
console.log(f);
});
}
window.addEventListener("load", function() {
if (window.ethereum) {
// use MetaMask's provider
App.web3 = new Web3(window.ethereum);
window.ethereum.enable(); // get permission to access accounts
} else {
console.warn(
"No web3 detected. Falling back to http://127.0.0.1:9545. You should remove this fallback when you deploy live"
);
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
App.web3 = new Web3(
new Web3.providers.HttpProvider("http://127.0.0.1:9545")
);
}
App.start();
});
index.js 너무 많이 바꼈네요.. ㅜ 이렇게 하면 앞에서 했던 iphoneX 크롬 개발자 도구로 ㅜ쿼리가 되던데 바뀐 index.js 코드에선 안되네요. 뭐가 잘못된 건가요?
답변 1
강의가 검은 화면으로 나옵니다.
0
48
1
nosql -> sql 비교
0
34
1
studio 3t 설치시 문의
0
37
1
https://my-company.site/ 접속
0
61
3
tailwind 1279부터 768까지 모바일형과 컴퓨터형의 컴포넌트가 같이 보임
0
49
3
notion 수정
1
55
1
9강에서 'Ch-9-1. GitHub 저장소 링크' 오류
0
69
1
강의자료 요청드립니다.
0
47
1
tailwind 설치 명령어 관련 질문
0
65
2
프로젝트 실행이 되지 않아 menu API 테스트가 불가합니다 ㅠ
0
134
9
3-3 트랜잭션이란 무엇인가 강의자료는 없나요?
0
86
2
font.html azure blob에 다시 올려줘야하는거 맞을까요?
0
45
1
질문] 에러처리 관련 문의
0
72
2
커넥션 min, max 설정과 관련하여
0
50
1
강의 내용은 훌륭하나, 환경 설정 오류 때문에 진도를 나갈 수 없습니다. 20년 버전 강의.
0
60
1
tailwind 화면 크기에 따른 ui 변화 기준
0
73
1
프로젝트 환경 세팅할 때 최신 노드 버젼을 사용하시는 분들은 참고하셔도 좋을 것 같아요~
2
80
1
강의_34] 공통 모듈 관련 질문입니다.
0
85
2
깃헙 질문
0
79
2
강의 1-1 수업노트의 로드맵 링크가 작동하지 않습니다.
0
74
1
Compass
0
50
1
npm i하면 바로, 라이브러리 오류없이 받아지고, 구동되는 소스는 없나요?
0
52
1
관리자 자동 로그아웃 문의드립니다.
0
79
1
예제 파일좀 올려주세요
0
411
2





