使用javascript、solidity和html时出现Web3模块未定义错误
我正在尝试为我的solidity合同构建UI。到目前为止,文件如下:使用javascript、solidity和html时出现Web3模块未定义错误,javascript,html,solidity,Javascript,Html,Solidity,我正在尝试为我的solidity合同构建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.li
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
当我在localhost上运行服务器时,我得到一个错误,说没有定义web3。
有人能帮我吗??
谢谢你 我找到了答案。
我只需要在server.js文件中包含web3:
var express = require('express');
var Web3 = require('web3');