Ethereum, tokens & smart contracts.

Notes on getting started Part 2. web3.js

So once you have a wallet, are on a test net and have some ether ( read part 1. if any of this is not clear ) where to go next ?

Let’s start coding, web3.js and Solidity seem to be the entry points for interacting with the blockchain programmatically and making contracts & tokens, web3.js I think is a nice prequel to working with solidity, so let’s check it out first:

Docs

web3.js is the javascript API for interacting with the Ethereum blockchain, the easiest way to explain it is through a couple of basic examples. A cool and simple way to test some basic commands is via the parity/web3 console:

Let’s start by requesting my balance:

Importantly the balance is displayed in wei, not ether, but conveniently there is a function in the api that converts to ether (or other denominations)

Speaking of denominations, here they are in ether:

And in wei:

Sending ether from one account to another one:

At this point paritys web3 console crashed my browser 😐 , but upon reloading it presented a confimation/signing screen and the transaction went through !

Besides this I found the console rather limited and running one line commands is probably not ideal anyways, so I chose to move to Atom, node and web3. I spent a few days ! figuring out how to make it work, but finally I got it to run:

  • In Atom you have a couple of options for running node. I tried script and atom-runner, they both work fine.

With this setup you can now work within atom and connect to your parity node. ( we’ll try expanding this to work on solidty in the next post ).

  1. Start and connect parity (to a testnet) :

2. In Atom make a file ( test.js ) and start the connection ( I am just asking for my accounts right now ):

Let’s now try sending a transaction (we do need the UI when starting Parity for now) :

My Atom setup in case you were wondering:

Since my wallet is locked, I still need to unlock it via parity on the browser:

And once that is done I get a Transaction Hash ( or Tx) in Atom:

As mentioned before, you can check transactions ( even on test nets) on a block explorer : https://kovan.etherscan.io/ the above Tx thus would give us :

And how about if we don’t want to use a browser to unlock the wallet ?, you will need to start parity with the personal api enabled:

and in your node.js file use it to unlock your wallet:

For other api operations check: https://github.com/paritytech/parity/wiki/JSONRPC

What’s next ?: There is still some ground to cover before issuing smart contracts and tokens, I’ll be going over the basics of Solidity in the next part, but for now we have a basic setup and local development environment for interacting with the ethereum blockchain which should set you on the right path.

Cheers !

Keno

About the Author :

Born Eugenio Noyola Leon (Keno) I am a Designer,Web Developer/programmer, Artist and Inventor, currently living in Mexico City, you can find me at www.k3no.com

AI, Software Developer, Designer : www.k3no.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store