IS3101 Cryptocurrency & Blockchain
Lecture Lecture 10: Bitcoin Mining Pool
Tutorial 10: Tutorial 11:
dapps dapps
Copyright By PowCoder代写 加微信 powcoder
4 Mining pools
ANTMINER S19 PRO
● Cost: ≈HKD$80,000
● Expected time to find a
block: ≈45 months ● Expected revenue:
≈$2,000/month
Economics of being a small miner
Mining uncertainty
# blocks found in one year
probability (Poisson dist.)
Time to find first block
Probability density
Idea: could small miners pool risk?
Mining pools
● Goal: pool participants all attempt to mine a block with the same coinbase recipient
○ send money to key owned by pool manager
● Distribute revenues to members based on how much work
they have performed
○ minus a cut for pool manager
How do we know how much work members perform?
Mining shares
Idea: prove work with “near-valid blocks” (shares)
4AA087F0A52ED2093FA816E53B9B6317F9B8C1227A61F9481AFED67301F2E3FB D3E51477DCAB108750A5BC9093F6510759CC880BB171A5B77FB4A34ACA27DEDD 00000000008534FF68B98935D090DF5669E3403BD16F1CDFD41CF17D6B474255 BB34ECA3DBB52EFF4B104EBBC0974841EF2F3A59EBBC4474A12F9F595EB81F4B 00000000002F891C1E232F687E41515637F7699EA0F462C2564233FE082BB0AF 0090488133779E7E98177AF1C765CF02D01AB4848DF555533B6C4CFCA201CBA1 460BEFA43B7083E502D36D9D08D64AFB99A100B3B80D4EA4F7B38E18174A0BFB 000000000000000078FB7E1F7E2E4854B8BC71412197EB1448911FA77BAE808A 652F374601D149AC47E01E7776138456181FA4F9D0EEDD8C4FDE3BEF6B1B7ECE 785526402143A291CFD60DA09CC80DD066BC723FD5FD20F9B50D614313529AF3 000000000041EE593434686000AF77F54CDE839A6CE30957B14EDEC10B15C9E5 9C20B06B01A0136F192BD48E0F372A4B9E6BA6ABC36F02FCED22FD9780026A8F
Mining pools
Hey folks! Here’s
our next block to
Pool manager
prev: H( )
mrkl_root: H( )
0x00000000000a87790
0x000000000001e8709
0x00000000000000003f89
0x00000000000490c6b 0x0000000000007313f 0x0000000000045a161
00… 89… 1f…
Mining pool variations
● Pay per share: flat reward per share
○ Typically minus a significant fee
○ What if miners never send in valid blocks?
● Proportional: typically since last block
○ Lower risk for pool manager
○ More work to verify
● “Luke-jr” approach: no management fee
○ Miners can only get paid out in whole BTC
○ Pool owner keeps spread
Mining pool protocols
● API for fetching blocks, submitting shares ○ Stratum
○ Getblockshare
● Proposed for standardization with a BIP
● Increasingly important; some hardware support
Mining pool history
● First pools appear in late-2010 ○ Back in the GPU era!
● By 2014: around 90% of mining pool-based ● June 2014: GHash.io exceeds 50%
https://btc.com/stats/pool
Mining pools (as of
Are mining pools a good thing?
○ Make mining more predictable
○ Allow small miners to participate
○ More miners using updated validation software
○ Lead to centralization
○ Discourage miners from running full nodes
Can we prevent pools?
Terminology
EIP, Token, ERC 20, Interface, ERC 165, ERC 721, NFT
, DEX, DAO, ICO
● Decentralized application (Dapp/dapp/dApp)
● At a minimum, it is a smart contract and a web user
interface.
● More broadly, a Dapp is a web application that is built on top
of open, decentralized, peer-to-peer infrastructure services.
● In addition, many Dapps include decentralized storage and/or a message protocol and platform.
● Decentralized finance (DeFi) refers to financial applications built on blockchain technology that enable digital transactions between multiple parties.
● DeFi can involve lending crypto, sending crypto, or investing crypto.
● It removes the control banks and institutions have on money, financial products, and financial services.
● Decentralized exchange (DEX)
● A type of dapp that lets you swap tokens with peers on the
● You need ether to use one (to pay transactions fees) but they are not subject to geographical restrictions like centralized exchanges – anyone can participate.
Decentralized Autonomous Organization (DAO)
DAO was an organization created by developers to automate decisions and facilitate cryptocurrency
transactions.
DAO acted as a form of venture capital fund, based on open-source code and without a typical management structure or board of directors. To be fully decentralized, it made use of the Ethereum network. Implemented by smart contracts.
Fueled by ether, the DAO was designed to allow investors to send money from anywhere in the world anonymously.
The DAO would then provide those owners tokens, allowing them voting rights on possible projects.
In June 2016, hackers attacked causing DAO to hard fork. DAO was delisted from major cryptocurrency
exchanges.
However, the idea of the decentralized autonomous organization continues to grow.
● Initial Coin Offering (ICO)
● ICO is the cryptocurrency industry’s equivalent to an initial public offering (IPO).
● A company seeking to raise money to create a new coin, app, or service can launch an ICO as a way to raise funds.
● Interested investors can buy into an initial coin offering to receive a new cryptocurrency token issued by the company.
● This token may have some utility related to the product or service that the company is offering, or it may just represent a stake in the company or project.
Common Smart Contract
Terminology
● Solidity Interface
● ERC165 ● ERC721 ● NFT
● Ethereum Improvement Proposals (EIPs) describe standards for the Ethereum platform, including core protocol specifications, client APIs, and contract standards.
● Network upgrades are discussed separately in the Ethereum Project Management repository.
● Tokens can represent virtually anything in Ethereum: ○ reputation points in an online platform
○ skills of a character in a game
○ lottery tickets
○ financial assets like a share in a company
○ a fiat currency like USD
○ an ounce of gold
○ and more…
● ERC stands for “Ethereum request for comment,” and the ERC20 standard was implemented in 2015.
● An ERC20 token is a standard used for creating and issuing smart contracts on the Ethereum blockchain.
● Smart contracts can then be used to create smart property or tokenized assets that people can invest in.
● function name() public view returns (string)
● function symbol() public view returns (string)
● function decimals() public view returns (uint8)
● function totalSupply() public view returns (uint256)
ERC 20 Example
● function balanceOf(address _owner) public view returns (uint256 balance)
● function transfer(address _to, uint256 _value) public returns (bool success)
● function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
● function approve(address _spender, uint256 _value) public returns (bool success)
● function allowance(address _owner, address _spender) public view returns (uint256 remaining)
ERC 20 Example
● event Transfer(address indexed _from, address indexed _to, uint256 _value)
● event Approval(address indexed _owner, address indexed _spender, uint256 _value)
Solidity Interface
● An interface allows you to talk to another contract on the blockchain.
● Interfaces are similar to abstract contracts and are created using interface keyword.
● Key characteristics of an interface:
○ An interface can not have any function with implementation.
○ Functions of an interface can be only of type external.
○ An interface can not have a constructor.
● ERC 165, the Standard Interface identifier is used to publish and detect what interfaces a smart contract implements e.g., ERC 721 standards.
● It is very useful to list tokens in exchanges as it helps the operator(_address) identify the standard is implemented in the contract.
● ERC721 is a standard for representing ownership of non- fungible tokens, that is, where each token is unique.
● It is a more complex standard than ERC20, with multiple optional extensions, and is split across a number of contracts.
● non-fungible token (NFT)
● Also known as a “deed,” this is a token standard introduced
by the ERC-721 proposal.
● NFTs can be tracked and traded, but each token is unique and distinct; they are not interchangeable like ETH and ERC- 20 tokens.
● NFTs can represent ownership of digital or physical assets.
● ERC1155 is a token standard mainly used for NFTs (non- fungible tokens).
● With NFTs increasing in popularity and more artists wanting to create NFTs, it’s beneficial to have a token standard such as the ERC1155 to regulate these tokens.
Solidity Library:
● When you are working with numbers in any programming language you are subject to overflows.
● An overflow happens when the value of a number is bigger than the maximum possible value offered by the machine.
● SafeMath is a library package over Solidity’s arithmetic operations with added overflow
○ SafeMath restores this intuition by reverting the transaction when an operation overflows.
○ Using this library instead of the unchecked operations eliminates an entire class of bugs, so it’s recommended to
use it always.
● SafeMath is no longer needed starting with Solidity 0.8. ○ The compiler now has built-in overflow checking.
https://www.dapp.com/
Learn from real
world running smart contracts
https://www.stateofthedapps.com/
● What is Atra?
○ Services is a cloud platform that
helps you build, deploy, and maintain decentralized blockchain applications.
● Installing Metamask ○ A browser wallet
● Develop a TweetVote dapp
● Develop a Buy and sell dapp
● Adding Triggers and conditions ● Having multiple UI tab pages
References
• Narayanan et al. Ch 5
• https://ethereum.org/en/developers/docs/
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com