Adventures in Blockchain

Home / Blockchain / Adventures in Blockchain

It’s crazy how quickly you forget things when you don’t use them.  For example, I spent months learning blockchain, Solidity, smart contracts and how these all integrate.  Well, I have spent the last 5 days working through a prototype to build my own Token.  And a lot of the knowledge eventually came back to me…  but a lot slower than I would have liked.  So, the smart thing to do would be to document the things I just relearned.  So maybe I won’t forget it next time.

I used a lot of the material from Dapp University.   The problem is that the tutorial I was following is a couple of years old, and ultimately not exactly what I wanted to do, so it was good to remind me of “a” way to do it, but there are better ways.  Let me walk down the path of what I learned.

  1. Install node.js – since my development was all done in windows, everything requires a few extra hoops to jump through.  I had to install it globally with an executable, instead of installing it into my conda instance.
  2. Use Truffle.  This package has so many cool options, that without it, I can’t imagine developing in Solidity
    1. it’s an easy way to compile projects, migrate projects to any network setup in your truffle-config.js file.
    2. Truffle Boxes can let you start a project with everything you need, then you just need to update the given files and add your own stuff to it.  But it can give you starter websites and lots of code.  Great for starting out.
    3. truffle test is another handy command to quickly determine if your contracts work as expected.  You can couple these with chai for even more testing options.
    4. handy commands include:
      1. truffle compile
      2. truffle test
      3. truffle migrate –reset –network rinkeby
      4. truffle console
  3. Setting up the truffle-config.js file has a lot of subtle features and a lot of power.  Much of this depends on installing the correct packages.
      1. be sure to check your package.json to ensure you have the correct version and packages.
      2. Set your solidity version here.  Depending on what packages you choose, may force you to use a higher version.
      3. certain things can become obsolete, so pay attention and use your search engine to understand where errors came from.  it is often due to a version mismatch or  the package being complete replaced.  For example, Truffle-hdwallet-provider has become @truffle/hdwallet-provider since I originally did my blockchain projects.
  4. Be sure to install Ganache – and use it liberally while you are testing the contracts.
    1. Save a particular ganache instance so that you can copy several accounts into meta mask for easy use.
  5. Writing the smart contracts can be done in 2 ways…  both are pretty slick.
    1. Sublime Text with a bolt-on to help with the syntax.
    2. remix.ethereum.org – I totally forgot how handy this tool is.  It can connect to local files, or you could code the whole thing in their website.  Remix is nice because it offers you a compile option with just a push of a button.
  6. Build your smart contracts and test in tandem.  One of the lessons I walked away with from the DappUniversity tutorial is that it really does work well to write the test first, then add the code to the smart contract.
  7. Get to know Meta Mask really well.  I’m quickly learning that Meta Mask is the really the key to everything.
    1. it can link to any of the many Ethereum networks.  You can even configure it to talk to ganache on your local machine. (see point 3-1)
    2. Linking to a website is a little more cumbersome than I hoped, but still able to be linked relatively quickly, once you know the steps.  (I’ll do a blog post on this soon).
    3. install it ASAP.  in my opinion, it’s the initial steps to web 3.0.
  8. Get some rinkeby ether sooner, rather than later.  No matter what you choose to do, you’ll need this.  The cool thing is that a single wallet can hold Ether from multiple systems.  (or you could up different wallets like I did).
    1. https://faucet.rinkeby.io/
    2. you can get ether by simply doing a tweet or facebook post.  Then you can get as much as 18.5 Ether (and you can repeat it again after a certain time period if you need more).
  9. When you are ready to move a test network like rinkeby, Use Infura, not geth or something similar.
    1. Using Geth can work just fine, but dealing with the massive download (if you aren’t already doing it) takes a lot of time, and in my opinion a lot of extra hassle.
    2. Setup an infura site, make a project, and using @truffle/hdwallet-provider“, you can link your project using infura to talk to many different blockchains (mainnet, rinkeby, etc.)
  10. When you want to interact with your contract in the test network but haven’t build a frontend for everything, use Remix.
    1. Remix has a very nice interface that allows you to easily interact with your contract (I’ll do a post on this soon).

And this doesn’t even include the front end.  LOL.  Anyway, I hope some of these pointers can help, and there will be more posts in the future to go into details on these steps.

Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *