Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using web3 object on meteor server side code? #381

Closed
hems opened this issue Jan 31, 2016 · 7 comments
Closed

using web3 object on meteor server side code? #381

hems opened this issue Jan 31, 2016 · 7 comments

Comments

@hems
Copy link

hems commented Jan 31, 2016

I'm trying to use web3 from the server as i wish the server side code to do the interaction with the blockchain, so i can keep my application "transparent" to users, but web3 is undefined after adding this package.

my installation was simply: meteor add ethereum:web3

Any suggestions ?

@hems hems changed the title web3 object on the server? using web3 object on meteor server side code? Jan 31, 2016
@frozeman
Copy link
Contributor

frozeman commented Feb 2, 2016

Did you try this https://github.com/ethereum/wiki/wiki/JavaScript-API#adding-web3

var Web3 = require('web3');

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

@hems
Copy link
Author

hems commented Feb 2, 2016

i tried meteor add ethereum:web3 but web3 still undefined on the server, is that the expected behaviour ?

should i require it through npm ?

@hems
Copy link
Author

hems commented Feb 2, 2016

Even though i can see web3 @package.json is supposed to export to the server, i still get it undefined on meteor server code.

tests/embark [ meteor --version              
tests/embark * ] 2:41 am
Meteor 1.1.0.2

tests/embark [ node --version
tests/embark * ] 2:41 am
v1.2.0

# server/app.js
Meteor.startup( function(){

  console.log("Server started")

  console.log( "web3 ->", web3 )
})
W20160202-02:39:42.052(0)? (STDERR) ReferenceError: web3 is not defined
W20160202-02:39:42.052(0)? (STDERR)     at app/server/embark.js:1:36
W20160202-02:39:42.052(0)? (STDERR)     at app/server/embark.js:3:3
W20160202-02:39:42.052(0)? (STDERR)     at /Volumes/backpack/git/xxx/tests/embark/.meteor/local/build/programs/server/boot.js:222:10
W20160202-02:39:42.052(0)? (STDERR)     at Array.forEach (native)
W20160202-02:39:42.052(0)? (STDERR)     at Function._.each._.forEach (/Users/hems/.meteor/packages/meteor-tool/.1.1.3.pfjq9++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160202-02:39:42.052(0)? (STDERR)     at /Volumes/backpack/git/xxx/tests/embark/.meteor/local/build/programs/server/boot.js:117:5

@frozeman
Copy link
Contributor

frozeman commented Feb 2, 2016

The Web3 object is available (uppercase).

You need to instantiate it first. See the veering started guide on the web3.js docs page in the wiki.

On 01.02.2016, at 18:38, henrique matias [email protected] wrote:

i tried meteor add ethereum:web3 but web3 still undefined on the server, is that the expected behaviour ?

should i require it through npm ?


Reply to this email directly or view it on GitHub.

@frozeman frozeman closed this as completed Feb 2, 2016
@hems
Copy link
Author

hems commented Feb 2, 2016

@frozeman ooooooh gosh. my bad!

where is my n00b badge? ( :

@parthi2929
Copy link

Hi
In case of local testrpc its ok. but how to use testnet like rinkeby

@kn1g
Copy link

kn1g commented Dec 18, 2017

try
geth --rinkeby --rpc --rpcapi db, eth, net web3, personal --unlock="YOURACCOUNT"

e.g.
geth --rinkeby --rpc --rpcapi db, eth, net web3, personal --unlock="0x876h54e45hz..."

still use:
var Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants