DeFi Blockchain

JaxNode March 2021

Full Disclosure

  • I am not a Fiduciary
  • Please do not use this as financial advice
  • Don't take financial advice from anyone who bought an airplane
  • I own BlackBerry stock

DeFi topics

  • Money
  • Blockchain
  • Cryptocurrencies
  • Distributed Finance (DeFi)
  • Smart Contracts
  • Solidity
  • Distributed Applications (Dapp)
  • Non-fungible Tokens

What is Money

  • Social Contract for exchanging goods and services
  • Replaced the Barter System
  • Medium of Exchange
  • Measure of Value
  • Paper money replaced coins as Legal Tender
  • Most Paper money is now a Fiat currency

Crypto Currencies

  • Crypto for short
  • Digital money based on blockchain technology and is decentralized and encrypted
  • Can be used for purchasing products and services
  • Also just used as an investment

Paul Krugman

Bolivarian Republic of Venezuela

Inflation rate of 2665% this year

Was 350000% in 2019,

slowed to 2900%

in 2020

Was the richest nation in South America 20 years ago

Largest oil reserves in the world

20% of all US Dollars in circulation were minted in the last year

Legality

  • Russia initially skeptical, now embracing Crypto
  • Most mining in China
  • India has outlawed Bitcoin
  • Venezuela came up with their own (Petro)
  • Janet Yellen Treasury Secretary has concerns
  • Gary Gensler incoming SEC Chairman very pro Crypto currency
  • Gary Gensler taught a course at MIT on Cryptocurrency and Blockchain

What is Blockchain

  • Digital ledger
  • Chain of blocks of data
  • First made popular with Bitcoin
  • Can be used for all kinds of apps besides Cryptocurrencies

Blockchain principles

  • Combine data for a hash
  • Bitcoin uses Sha256 as its hash
  • Data can contain transactions for its data
  • Nonce is used to with the data to compute a hash with leading zeros
  • Blocks are added to one another with the previous hash as part of the data to create blocks

Demo

Cryptocurrencies

  • Bitcoin launched in 2009
  • Litecoin introduced 2011
  • Dogecoin introduced 2013
  • Ethereum launched in 2015
  • Bitcoin and Ethereum the largest
  • Cardano (ADA)
  • 100s of new 'Coins' launched in ICOs since
  • Many have disappeared as well

Bitcoin

  • Invented by Satoshi Nakamoto?
  • No one is sure if he actually exists
  • Started at $0.30, now worth > $50,000
  • Finite number of coins, no inflation
  • Miners earn coins through 'Proof of Work'
  • Bitcoin is based on a linear blockchain
  • Transactions take over 10 minutes 

Lite and Dogecoin

  • Meant to be more accessible
  • Also finite number of coins
  • Both use more efficient hash
  • Dogecoin started as a joke

Ethereum

  • Started in 2015 by Vitalik Buterin
  • Started as journalist for Bitcoin Weekly
  • Uses a Merkle tree instead of a linear blockchain
  • Also uses Smart Contracts
  • Introduced the Solidity programming language
  • Ethereum setup as a Non-profit
  • Ethereum network used not just for financial transactions, but for distributed applications

Environmental Impact

  • Bitcoin mining uses the amount of electricity produced by the entire nation of Argentina
  • Miners usually mine where electricity is cheap
  • Below $0.05 kWh
  • JEA costs $0.12334 kWh

PoW vs PoS

  • Proof of Work used for most Blockchains
  • Proof of Stake much more energy efficient
  • Proof of Stake Mining is done by stakeholders
  • Stakeholders are randomly picked to mine blocks
  • Ethereum is moving from PoW to PoS in layer 2
  • It will take a while for Ethereum to transition to PoS

Cardano

  • Cardano (ADA)
  • Uses Proof of Stake
  • Claims to be the most Eco-friendly Crypto
  • Create Smart Contracts with Plutus platform
  • Programmed in Haskell

Algorand

  • Founded by MIT professor Silvio Micali
  • Proof of Stake
  • Permissionless Blockchain
  • Uses Verifiable Random Function
  • Smart Contracts written in version Python

Distributed Finance

  • Banks and others institutions are using or investigating Blockchain technology
  • Allow for financial transaction without the need of banks or fiat currencies
  • First big use of Bitcoin was Silkroad
  • Some currencies offer savings rates as high as 9%
  • Money can be earned through proof of stake and mining
  • Largest mining farms in China and Russia

Smart Contracts

  • Ethereum first to introduce
  • Can create contracts with logic
  • Solidity is a Touring complete language for creating smart contracts
  • Contracts can be used to guarantee that a financial transaction is only used for a certain type
  • They can also be used for distributed applications
  • Processing a transaction on Ethereum or other networks requires 'fuel' 
  • Fuel costs on Ethereum's network can be over $10 dollars

Solidity

  • Language for programming the Ethereum Network
  • Use it to create Smart Contracts
  • Touring Complete language
  • Based on JavaScript and C++
  • Supports types and inheritance
pragma solidity >= 0.7.0 <0.8.0;

contract Coin {
    // The keyword "public" makes variables accessible from other contracts
    address public minter;
    mapping (address => uint) public balances;

    // Events allow clients to react to specific
    event Sent (address from, address to, uint amount);

    // Constructor code is only run when the contract
    // is created
    constructor() public {
        minter = msg.sender;
    }

    // Sends an amount of newly created coins to an address
    // Can only be called by the contract creator
    function mint(address receiver, uint amount) public {
        require(msg.sender == minter);
        require(amount < 1e60);
        balances[receiver] += amount;
    }

    // Sends an amount of existing coins
    // from any caller to an address
    function send(address receiver, uint amount) public {
        require(amount <= balances[msg.sender], "Insufficient balance.");
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        emit Sent (msg.sender, receiver, amount);
    }
}

Solidity Tools

  • Visual Studio Code extension
  • Node.js based compiler
  • Web3 JS Library
  • Truffle for testing
  • Ganache personal blockchain
  • Drizzle React based Redux store
  • Remix is an online Solidity playground

Demo

Dapps

  • Decentralized applications
  • Ethereum Network is used for financial and many other types of applications
  • Games and Social networks can run as Dapps
  • Use fuel or 'Gwei' to pay for transactions
  • Interplanetary Filesystem or (IPFS) is a Dapp
  • Websites can be hosted on IPFS using ipfs://

Binance

  • Binance is a Crypto exchange and network
  • Node.js APIs for monitoring and buying Crypto
  • They have there own network for processing Smart Contracts
  • Based on Ethereum's network
  • It is a centralized network

Demo

Kings of Leon

Non-Fungible Tokens

  • Non-Fungible Tokens (NFTs)
  • Also based on Blockchain
  • Being used for 'Digital Art'
  • Kings of Leon first band to release album as NFT
  • OpenSea.io market place for Digital Art
  • ERC721 specification for Ethereum
  • Mintbase, Cargo or Rarible can be used for creation

Questions?

Links

  • slides.com/davidfekke/defi
  • github.com/Jaxnode-UG/blockchain-demo
  • github.com/Jaxnode-UG/public-private-key-demo
  • github.com/Jaxnode-UG/truffle-event-tests
  • remix.ethereum.org

DeFi

By David Fekke

DeFi

Presentation on DeFi, Blockchain, Solidity and Smart Contracts

  • 590