Can someone outline the steps involved in interacting with a simple Ethereum contract (ie. greeter) from html?
I have created a test net, mined ethers and also created the "greeter" contract. When I run admin.nodeInfo, the TCPPort is 30303
I know I need web3 + JSON ABI of my contract + address.
1) I don't know how to incorporate web3. The
examples I have seen shows the "require" in the html page. Is this running on node.js?
2) I don't know what port# to put in place of 8545 in web3.setProvider(new web3.providers.HttpProviders("
http://localhost:8545")
Any help would be appreciated.
Comments
1) Nginx
I started geth with --rpc flag pointing to a port.
I am using nginx web server. I've changed the port using --rpcport to point to the port I am using. (The web page domain is local so I didn't bother with rpccorsdomain.)
I included ethereum.min.js in the html
I opened up browser and pointed to the page. The page comes up but when I try to execute the script, I get "web3 is not defined" when the code calls web3.eth.contract(....)
Is there anything else I need to do to enable web3 on nginx server?
2) Meteor
So I then decided to install meteor and the added ethereum:web3 and now it is working.
Is there an ethereum web3 module for nginx?
[Env ubunt 14.04, on AWS box ]
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy
sudo npm install web3
Error
npm ERR! Error: No compatible version found: [email protected]'debris/bignumber.js#master'
npm ERR! Valid install targets:
npm ERR! ["1.0.0","1.0.1","1.1.0","1.1.1","1.2.0","1.2.1","1.3.0","1.4.0","1.4.1","1.5.0","2.0.0","2.0.1","2.0.2","2.0.3","2.0.5","2.0.6","2.0.7","2.0.8"]
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:719:10)
npm ERR! at /usr/share/npm/lib/cache.js:638:10
npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!
npm ERR! or email it to:
npm ERR!
npm ERR! System Linux 3.13.0-48-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "web3"
npm ERR! cwd /home/ubuntu
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ubuntu/npm-debug.log
npm ERR! not ok code 0
npm -v # returns 1.3.10 for me.
The solution is to upgrade npm
sudo npm install -g npm
source ~/.bashrc
npm -v # check the version, it should be >=3.5.2 (currently version)
now you can proceed with
sudo npm install web3