Skip to content

Instantly share code, notes, and snippets.

@morenoh149
Last active January 27, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morenoh149/e12e315c7e2c320b5b1eda2847a3b2cd to your computer and use it in GitHub Desktop.
Save morenoh149/e12e315c7e2c320b5b1eda2847a3b2cd to your computer and use it in GitHub Desktop.
Intro to blockchain programming in js

Introduction to Blockchain Programming, Jan 2020

Explain blockchain

Chain of blocks

  • https://anders.com/blockchain/blockchain
  • Hashing function
  • coinbase transaction
  • the ledger is all of the transactions
  • How many confirmations required?
  • blocktime
    • 10 minutes bitcoin
  • guessing game for nonce
  • Verify not trust
    • you can get a copy of the full ledger (record of account) for 400 gb

Addresses

  • make an address
    • choose a random number in a large enough space, the probability of collision is near-zero
    • make a random number, generate a private and public key pair from that number
    • no one can guess the private key from the public key
    • no central authority for addresses
    • with mouse entropy
    • with javascript
  • 2^256 feels like infinity (more numbers than atoms in the universe)
  • 2^160 (10^48) is the order of the private keys (number of possible addresses)
  • number of atoms in the universe is 10^80
  • control of the private key is the ownership of the funds (control of the funds)

Transactions

Mining

  • artificial scarcity - halving and 21 million supply bitcoin supply https://bashco.github.io
    • If the mining power had remained constant since the first Bitcoin was mined, the last Bitcoin would have been mined somewhere near October 8th, 2140. Due to the mining power having increased overall over time, as of block 367,500 - assuming mining power remained constant from that block forward - the last Bitcoin will be mined on May 7th, 2140. https://en.bitcoin.it/wiki/Controlled_supply#Projected_Bitcoins_Long_Term
  • _ block space is a scarce commodity, getting a transaction mined can be seen as purchasing a portion of it. By analogy, on average every 10 minutes a fixed amount of land is created and no more, people wanting to make transactions bid for parcels of this land. The sale of this land is what supports the miners even in a zero-inflation regime. The price of this land is set by demand for transactions (because the supply is fixed and known) and the mining difficulty readjusts around this to keep the average interval at 10 minutes._
  • https://digiconomist.net/bitcoin-energy-consumption total cost of network in 2019 is ~$3.6 billion usd per year

Charts

put address on website

  • generate qr code
  • https://www.btcfrog.com/ - generates qr codes from btc addresses
  • place png on website to let people send you btc

mobile wallet

Use Blockexplorer

Using electrum (lite wallet)

make webpage with mycelium gear

  • mycelium gear
    • https://gear.mycelium.com
    • can generate a button you can copy paste into website to accept btc payments
    • first make address in a wallet (Note: must be legacy non-segwit address)
    • then gateway
    • then button
    • then serve on local webpage

Javascript exercises

Security

  • do not send btc to people acting like your friends, on the internet it is easy to impersonate people
    • Harry Morano is requesting $100 on venmo
    • check the name for misspellings!

Resources

@morenoh149
Copy link
Author

Thread with more info for programming a txn bitsnaps/bitcoin-generator#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment