Notes

What is Gas

  • Gas is needed to incentivize miners to pick up and validate transactions. It’s a small fee paid for the cost of each bit of code executed to complete a smart contract. While the gas is specific to execution costs, it can be converted to its equivalent value in ether and given to the miner as reward for their effort.

Debugging

Testing

Code Snippets

Running Ganache

  • The mnemonic can be changed, and is auto-generated when running Truffle or Ganache the first time, copy and save the twelve words. This is useful if you need to use the same accounts for testing and have to re-run the Ganache server.
  • host 0.0.0.0 is set to serve from within a container.
    ganache-cli --host 0.0.0.0 --mnemonic "twelve words provided by ganache the first time the command is run"
    

Setting up Web3 & Infura

  • From a Nix shell run node <file-name.js>.
    var Web3 = require('web3');
    var web3 = new Web3(Web3.givenProvider || 'https://rinkeby.infura.io/v3/<PROJECT-ID>');
    

Development Environment

A Docker container running NixOS with a Nix Shell

  1. Build a container and install dependencies.
    docker run --rm --volumes-from=nix -it -v $(pwd):/app -w /app -p 3000:3000 -p 3001:3001 -p 8545:8545 nixos/nix nix-shell /app/.config/build.nix
    
  2. To run the container.
    docker run --rm --volumes-from=nix -it -v $(pwd):/app -w /app -p 3000:3000 -p 8545:8545 nixos/nix nix-shell /app/.config/eth.nix
    

    Gists

Reference

Tools

  • Etherscan - Block explorer used to search Ethereum analytics.
  • Metamask - Browser extension for carrying out Ethereum transactions.
  • Remix - An online integrated development environment for creating smart contracts in Solidity.
  • web3.js - Access data from the Ethereum blockchain & info seen in Metamask or Etherscan can be accessed.
  • Infura - Provides the connections needed to access data on the Ethereum blockchain.
  • Ganache - Builds a local blockchain you can use to build and test Dapps.
  • Truffle - The Dapp framework for Ethereum, build, test and deploying.
  • Solidity - Solidity is an object-oriented, high-level language for implementing smart contracts.
  • Geth - Sets up a local Ethereum node on your system.
  • Dapp Stores

Ethereum

Geth

Ethereum GUI