My blockchain learning journey

By William Okafor on ALTCOIN MAGAZINE

William Okafor
The Dark Side
Published in
5 min readFeb 25, 2019

--

How i was able to install the latest stable version of web3 on my windows machine

Allow me to start by giving you a little glimpse into my journey into this field.

As a software engineer who has had a major focus in web development for years, i expected things with this new field of decentralized applications and the immutable ledger system called blockchains to be as stable as I have been used to especially with backward compatibility but little did I know.

So I recently studied up on blockchains, the cryptocurrency, after which I couldn’t wait to start writing my own smart contracts which I eventually did start and all was great until I got to the point where I wanted to push my code online to be used by actual people other than me.

Now did I mention that I learnt majorly by using Udemy tutorials but the latest ones I found was released in early 2018? And I consumed as much of these resource as I could find on the internet?

Well i did and when the time came for me to go live, that was when I got to find out that a lot of resources I had been studying as well as others I was still stumbling upon for building on the Ethereum blockchain were really outdated and by outdated, I mean that applying their methods/codes verbatim broke your code every time.

Ethereum blockchain promises to be at the center of the new web

But then this was not really the fault of the creators of these content but largely because the technologies in this space is in a lot of flux hence it has been faced with several upgrades with many of them having terrible backward compatibility with each other.

Therefore I decided to give walk-throughs on how I solved some of the bugs I encountered in this journey and today, I would be talking about how i deployed my Dapp to ropsten test net and started interacting with it from the client side all using truffle.

They must love this guy.

Let’s get started

Before I was able to deploy/connect the ropsten testnet with infura, I needed a much more recent version of web3 than what was provided out of the box by the truffle-vue box I was using so I needed to install the latest one and I had troubles doing that on my machine till I did these

It’s totally fine if the previous sentence makes little or no sense to you right now.

Node.js

I had to upgrade to the latest version of Node. You can download it here

NB: To keep things short, i would be using the truffle-vue box as that would give us a head start.

Node-Gyp

Node-gyp compiles native addons (Linux, Mac, Windows) into node.js packages and we would be needing it here.

Run npm i -g node-gyp

Python 2.7

I already had python 3 on my pc but Node-gyp isn’t compatible with that so i had to install 2.7 and then I ran npm config set python python2.7 to set it to be the version used by npm and npm will in turn pass this option to node-gyp when needed.

Windows Build Tool

I initially ran `npm install -g windows-build-tools` but it broke everything but after hours of research, I found that the most stable version is version 4.0.0 hence I ran ` npm install -g windows-build-tools@4.0.0`

NB: Please run the above in your terminal having admin rights

Then i set the environment variable VCTargetsPath to the directory location where Microsoft.Cpp.Defaults.props is installed. Mine was in c:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\v140

I restarted my pc

Web3 installation

Subsequent attempts to pull in web3 still threw a ton of errors over and over again :’(.

I went into even more research to find out what I was doing wrong and after long hours (days maybe) of debugging I realised I was missing a package that web3 was dependent on called scrypt

Okay pull in scrypt and everyone would be happy, I said to myself. I ran npm i scrypt and guess what happened?…

I legit questioned everything I knew about software engineering at this point

After feeling shitty for a while I perused through the error logs and found nothing then I research on some keyword and I found that scrypt was in turn dependent on a package called nan (short for Native Abstraction for Node.js) but this package wasn’t installed so I did the following:

npm i nan scrypt

After this, pulling in web3 worked like a charm.

From my research at the time of writing this post, version 1.0.0-beta.36 of web3 was the most stable to use

The hard parts of starting out is done and since I prefer short and precise articles I would like to keep mine that way too so in my next article, I would be talking about how to I deployed my smart contract to the ropsten test net with infura and if it’s not too long already, I would talk about how I made my client side interact with my smart contract on the ropsten test net in my next article.

And that’s it! I hope this helped you and I’d see you next time, Cheers!

Follow us on Twitter, InvestFeed, Facebook, Instagram, LinkedIn, and join our Discord and Telegram.

Read about our upcoming Altcoin Magazine Mastermind Event here.

--

--