Frank Sung
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Blockchain ## 20180331 [TOC] ### Links Chatroom: https://gitter.im/taipeichain/Lobby Today's Slides: https://goo.gl/CGURzG Setup Links: https://gist.github.com/yhuag/5d8ee2fd46baff47edc923134048481c Contracts:https://github.com/BlockchainEduNet-HK/smart-contract-repo/tree/master/examples ### Additional Info CryptoKitties: https://www.cryptokitties.co 簡化支付驗證: https://goo.gl/MxvUq6 Blockchain Explorer: https://etherscan.io https://ropsten.etherscan.io EtherAddressLookup: https://goo.gl/LzLcGQ Nonce explanation:https://goo.gl/xj9YFm Wei & Finney & Ether:https://forum.ethereum.org/discussion/304/what-is-wei Ivan on Tech \(Youtube\): https://www.youtube.com/channel/UCrYmtJBtLdtm2ov84ulV-yg PoA: https://en.wikipedia.org/wiki/Proof-of-authority https://goo.gl/1T52Ff -- Parity:https://www.parity.io/ Remix:https://remix.ethereum.org/ OpenZeppelin:https://github.com/OpenZeppelin/zeppelin-solidity How to Code Your Own CryptoKitties: https://medium.com/loom-network/how-to-code-your-own-cryptokitties-style-game-on-ethereum-7c8ac86a4eb3 Kovan的幣可以從這裡拿:https://gitter.im/kovan-testnet/faucet ### Voting Demo ```javascript= pragma solidity ^0.4.13; import "github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol"; contract Voting { using SafeMath for uint; uint[] candidateList; // list (optional) mapping (uint => uint) public candidates; // ID -> votes mapping (address => bool) public voted; modifier isValidCandidate(uint candidateID){ require(candidateID>=0 && candidateID<3); // 0, 1, 2 _; } modifier hasNotVoted(){ require(!voted[msg.sender]); // require(voted[msg.sender] == false); _; } function Voting() public { // constructor candidates[0] = 0; candidates[1] = 0; candidates[2] = 0; candidateList = [0, 0, 0]; // list init (optional) } function vote(uint candidateID) public isValidCandidate(candidateID) hasNotVoted() { candidates[candidateID] = candidates[candidateID].add(1); // one vote voted[msg.sender] = true; } function getVote(uint candidateID) public isValidCandidate(candidateID) constant returns (uint) { return candidates[candidateID]; } } ``` ### Simple QA * **假設今天比特幣2100萬個都挖光了,那誰要負責記帳呢?** - Short answer: No one :) - Long answer: 比特幣的mining reward會隨著挖出的總量半衰遞減,當mining reward數年後小於一個金額threshold,之後挖礦唯一的誘因incentive就完全倚靠transaction fee了 * **礦工可以得到比特幣的來源有兩個: 1. 加入新區塊的礦工(老師說的數學樂透), 猜中數字可以得錢; 2. 每一筆交易都會有transaction fee** - Answer: 每個Block都含有數百~千個transaction,所以當每個Block被mined時會出現兩份獎勵rewards: 1. Transanction fee 總和 2. Block reward \(依照現在區塊高度Block Height\) * **兩個礦工都可以從transaction pool中撈取transaction到自己的block(記帳),但只有猜中數學樂透的人才可以把block公布(創造新的block) 所以說, 假設今天minerA猜中數學樂透, A所公布的block成為最新的block,那麼只有minerA可以得到該block中所有transaction的transaction fee嗎?** - Answer: 沒錯, 不過假設現在Block Height是100, 任何時間點算出第101 Block的miner**都可以**broadcast給周圍的peers, 接下來就看看該miner發布的夠不夠早, 周圍的peers願不願意把這個101th Block接上他們自己的chain \(如果是他們收到的第一個101th Block, 接受率最高\), 如果被接受了,該miner就會贏得所有的Transaction fee + Block reward ## 20180401 KeepingYouAwake(only for mac):https://github.com/newmarcel/KeepingYouAwake ### ERC20 ERC20:https://en.wikipedia.org/wiki/ERC20 Contract:https://gist.github.com/yhuag/e443af8685d5671e25b9761ceb334997 ### Pet Shop http://truffleframework.com/tutorials/pet-shop install npm, ganache(ganache-cli), then input in your terminal ```bash= npm install -g truffle mkdir ~(yourpath)/pet-shop && cd ~/(yourpath)/pet-shop truffle unbox pet-shop ``` add "Adoption.sol" to contracts add "2\_deploy\_contracts.js" to migrations {%gist ysya/949617974ae1e7bb53ed2a838961203e%} then ```bash= truffle compile truffle migrate ``` replace app.js https://raw.githubusercontent.com/ysya/trufflepetshop/master/src/js/app.js then ```bash= npm run dev ``` open your browser and go to localhost:3000.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully