0

I'm trying to interact with a private blockchain from JavaScript code. For that I've provided an RPC address to each node and extended multiple apis using -rpcapi. Now if I'm using geth attach http://127.0.0.1:8546 I'm able to use admin apis in new console, but when I use a web3 object with same address, it doesn't recognize admin api.

var Web3 = require('web3');
let express = require('express');
const bodyParser = require('body-parser');

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8101"));
}

console.log('web3 miner',web3.miner);//here it gives undefined

and the command i used to run private blockchain is

geth --port 30303 --networkid 58343 --datadir ./datadir --rpc --rpcport 8101 --rpcapi "eth,net,web3,personal,miner" console
  • its give undefined on web3.admin – sandeep singh Jan 10 at 11:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.