Trying to use web3-utils.
I installed the package via NPM , however, I am getting the error that sha3 is undefined..
TypeError: Cannot read property 'sha3' of undefined
at C:\block2\deliver.js:12:28
at Layer.handle [as handle_request] (C:\block2\node_modules\express\lib\router\layer.js:95:5)
at next (C:\block2\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\block2\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\block2\node_modules\express\lib\router\layer.js:95:5)
at C:\block2\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\block2\node_modules\express\lib\router\index.js:335:12)
at next (C:\block2\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\block2\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\block2\node_modules\express\lib\router\layer.js:95:5)
CODE:
var express = require('express');
var app = express();
Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var util = require('web3-utils');
app.get('/endpoint', function(request, response) {
var id = request.query.id;
response.end(web3.utils.sha3('test'));
});
app.listen(3000, '127.0.0.1', function() {
console.log('Listening to port: ' + 3000);
});
web3.version
?web3.utils.sha3
is available in the latest 1.0.0-betas, but not in the "release" branch, 0.20. Which version is installed bynpm
changed recently. Best to check.web3
version? @benjaminionweb3.version
in the node console (after loading web3 as above).