我正在尝试为我的固定合同建立UI。到目前为止,文件如下:
index.html : which contains ui part(tables, buttons, etc)
server.js:
var express = require('express');
var app = express();
app.use('/', express.static(__dirname + '/'));
app.listen(8080,() => console.log('Example app listening on port 8080!'));
index.js:
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
abi = JSON.parse('[{"constant":true,"inputs"......');
// In your nodejs console, execute contractInstance.address to get the address at which the contract is deployed and change the line below to use your deployed address
VotingContract = web3.eth.contract(abi);
contractInstance = VotingContract.at('deployed address name');
//rest of the functions required..
Solidity file: this contains the contract that will deployed on the blockchain
当我在本地主机上运行服务器时,出现错误,提示未定义web3。 谁能帮我这个?? 谢谢!!!
答案 0 :(得分:0)
我找到了答案。 我只需要在server.js文件中包含web3:
var express = require('express');
var Web3 = require('web3');