powered by Coinlib
Showing posts with label Bitcoin. Show all posts
Showing posts with label Bitcoin. Show all posts

Sunday, March 3, 2019

Buying and Selling Bitcoins



You can buy bitcoins from anyone who has them. Likewise you can sell bitcoins to anyone who wants them. Fortunately, there are various places where you are likely to find a group of people willing to trade at competitive prices - exchanges. Just like stock exchanges, Bitcoin or cryptocurrency exchanges are places (usually websites) that attract traders. However, you don’t buy bitcoins from the exchange itself. Just like a stock exchange, where you buy shares from another user of the exchange rather than from the exchange itself, a cryptocurrency exchange is the website that allows people to buy and sell between themselves. The exchange itself is just the location that brings together buyers and sellers, and people go there because they know they are likely to get the best prices there.

In financial services jargon, the exchange is an order matching engine. It matches buyers and sellers. It also acts as the central clearing counterparty. All matched trades appear to be against the exchange rather than between the customers directly, providing anonymity for customers. Finally, the exchange is the cash and asset custodian. It controls customers’ fiat money in its bank account and cryptocurrencies in its wallet.

Exchanges are based in different countries and support different fiat currencies and different cryptocurrencies. They all work roughly the same way using the same four steps: create account, deposit, trade, withdraw. To use an exchange, just like a bank, you need to open an account.
Exchanges are coming under increasing regulatory scrutiny due to the fact that they process large amounts of money. The top cryptocurrency exchanges match billions of dollars of buys and sells per day. Most legitimate exchanges follow a similar account opening procedure to banks, where new customers submit details and evidence of their identity, for example passport and utility bills. The documentation needed may become more onerous in proportion to the value of fiat or
cryptocurrencies you plan to transact, in a progressive risk-based approach. Exchanges are now big business and take these processes seriously. Once the exchange is satisfied, your account is created. Then you can log in and the next step is to deposit.

Before you can attempt to buy or sell anything on an exchange, you need to fund your account. This is like funding an account with a traditional broker before being allowed to buy traditional financial assets. Exchanges have bank accounts and cryptocurrency wallets. In order to fund your account you click on ‘Deposit’, then follow the instructions. If you are funding your account with fiat currency (presumably in order to buy cryptocurrency), then the exchange will display a bank account for you to make a fiat currency transfer to. If you are funding your account with cryptocurrency, (presumably to sell for fiat currency or trade for a different cryptocurrency) then the exchange will display a cryptocurrency address for you to make a cryptocurrency transfer to. Once exchange has detected the transfer to their bank account or cryptocurrency address, the balance will be reflected in your ‘account balance’ on the exchange’s website, and you are ready to trade.

Wednesday, February 27, 2019

Software Wallets & Hardware Wallets



You may hear that bitcoins are stored in wallets. If this were true, then if you copied your wallet you’d own double the number of bitcoins. Clearly you couldn’t have digital money that works this way. So no, bitcoins are not stored in wallets. So where are bitcoins stored? Ownership of bitcoins is recorded on Bitcoin’s blockchain, which is, as we have seen, the database replicated on over 10,000 computers around the world containing every Bitcoin transaction ever. So you can look at that database and see that at this time, a specific address has a specific number of bitcoins associated with it. Bitcoin’s blockchain doesn’t store balances of accounts (it is not a list of account numbers and corresponding BTC balances), it stores transactions. So to get the current balance of any account, you need to look at all the inbound and outbound transactions through that account. Bitcoin wallets store private keys (not bitcoins) and their software makes it easy for the user of the wallet to see how many coins they control and to make payments. If you cloned your wallet, you would be cloning your private keys, not doubling your bitcoins.

Bitcoin wallets are apps that can: create new Bitcoin addresses and store the corresponding private keys; display your addresses to someone who wants to send you a payment; display how many bitcoins are in your addresses; make Bitcoin payments.Creating new Bitcoin addresses is an offline operation and involves creating a public and private key pair.

When someone wants to send you bitcoins, you need to tell them your address - like telling someone your bank account number so they can send you money. There are a few ways to do this. One popular way is by showing it as a QR code. QR codes are not magic. They are just text, encoded in a visual way that makes it easy for QR code scanners to read the code and convert it back into text. Another way is just to copy and paste the address itself.

The wallet needs to access an up to date version of the blockchain in order to be aware of all the transactions going in and out of the addresses it is keeping tabs on. The wallet, software can do this by either storing the entire blockchain and keeping it up to date (this is called a full node wallet) or by connecting to a node elsewhere which does the heavy lifting (this is called a lightweight wallet). A full node wallet would contain over a hundred gigabytes of data and would need to be constantly connected over the internet to other Bitcoin nodes. So in many cases, especially on mobile phones, this is not practical so the wallet software is lightweight and connects to a server which hosts the blockchain.

As well as reading the account balances, the wallet needs to be able to make payments. To make a Bitcoin payment, the wallet generates a bundle of data called a ‘transaction,’ which includes references to the coins that are going to be spent (transaction inputs consisting of unspent outputs of previous transactions), and which accounts the coins will be sent to (new outputs). This transaction is then digitally signed using the relevant private keys of the addresses holding the coins. Once signed, the transaction is sent to neighboring nodes, via its server node if it is a lightweight wallet, or directly to other peers if it is a full node wallet. The transactions eventually find their way to miners who add them to blocks.

Good wallet software has more functionality, including the ability to back up private keys (encrypted with a passphrase) either to a user’s hard drive or to a cloud storage server somewhere, to generate one-time use addresses for privacy, to hold addresses and private keys for multiple cryptocurrencies. Some are even integrated with exchanges to allow users to convert between one cryptocurrency and another directly from within the wallet software. Often wallets will allow you to split keys or set up addresses that require multiple digital signatures to spend from.

Sometimes Bitcoin wallets can have a hardware component. Private keys are stored in chips on small handheld devices. Two popular hardware wallets are called ‘Trezor’ and ‘Ledger Nano’, but there are others. These devices are specifically designed to store private keys securely and only respond to certain pre-programmed requests, for example, ‘Please sign this transaction’, and not, ‘Show me the private key you are storing’. Because the private key is stored on hardware that is not connected to the internet and can communicate with the outside world only via a limited set of pre-programmed interfaces, it is much harder for a hacker to gain access to the private keys.

The user interface software is run on an online machine. When it comes to the critical part of the transaction (the signing), the unsigned transaction is sent to the hardware wallet, which returns the signed transaction without revealing the private key. Hardware wallets are more secure than
software-only wallets, but nothing is infallible.

The phrase ‘keeping coins in cold storage’ was popular in 2013-17 before hardware wallets became widely available. Remember, you don’t store bitcoins, you store private keys. ‘Cold storage’ is keeping a note of those private keys on offline media, such as a piece of paper or a computer not connected to the internet. There are many ways of storing them. You can memorise keys if you have a good memory, you can print them out on bits of paper, you can even engrave them on a ring that you wear. You could store them on an offline computer which, for increased security, should not have a modem or network card. You could write them down and put them in a bank’s locked deposit box. These are all methods of storing your private keys offline.

If you do keep private keys on a device or printed out, you wouldn’t want someone else to be able to see it and use it to steal your bitcoins. So one way of increasing security is to first encrypt the private key with a passphrase that you can remember and then store or print out the encrypted result. Passphrases are a lot easier to remember than private keys. This means that even if someone gets hold of the device or print out, they’d need to decrypt it with your passphrase before the private key is revealed. You can split keys or use multi-sig addresses for further security. This means if one part is found by a thief, it is useless without another part, and also means if one part is lost, the other two will still work. Remember, you are trying to simultaneously guard against two things: loss of keys and theft of keys.

A hot wallet is a wallet that can sign and broadcast transactions without manual intervention. Exchanges, who control many bitcoins need to manage lots of Bitcoin payments, as we will see later. They often have a ‘hot wallet’ that controls a small proportion of their total bitcoins. Customers of exchanges like to withdraw bitcoins from the exchanges by clicking a button, causing an automated process to run to make and sign a Bitcoin transaction moving bitcoins from the exchange’s hot wallet to the user’s personal wallet. This means that somewhere, a private key belonging to the exchange must be stored on a ‘hot’ machine connected to the internet. There is a trade-off between security and convenience. Online machines are easier to hack than offline machines, but can automate the process of creating and broadcasting Bitcoin transactions. Due to this trade-off, exchanges keep only a small fraction of BTC in hot wallets, enough to satisfy customer demand, similar to banks that keep a small amount of cash in tellers’ tills at branches.

Bitcoin’s Price



Like gold or oil or any other asset, bitcoins have a value that can be priced in USD or any other currency. This means there are people who are willing to exchange BTC with USD, usually using cryptocurrency exchanges, marketplaces which attract buyers and sellers. On exchanges you can see indications of supply and demand for cryptocurrencies at any price level (more on these later). You can also buy and sell bitcoins with anyone in the world, physically on the streets or over the internet, or using brokers who mediate between buyers and sellers, or who trade on their own behalf. To trade BTC, you simply need the ability to send or receive BTC and the ability to receive or send the other asset, usually a local currency.

Like any other market-traded asset, the price of Bitcoin fluctuates with supply and demand. At any point in time, people trade at prices that they are comfortable buying or selling at. If there is more buying pressure and people want to buy more bitcoins, prices will increase. If there is selling pressure and people want to sell more bitcoins for fiat currencies, then the price at which the bitcoins change hands will drop. Later we will go into more detail about how cryptocurrencies and tokens can be priced, but here we will look at specifically Bitcoin’s price. Bitcoin’s price has been a wild ride. A recent price rise to almost $20,000 USD per Bitcoin and subsequent fall the $4,000 levels has caught the media’s attention. But this is not the first time Bitcoin has been this volatile. Bitcoin appears to be cyclically volatile, with each cycle as dizzy as the previous.

Tuesday, February 26, 2019

Bitcoin Mining



Although anyone can mine, the process has become so intensive that new hardware and chips are created which are designed to be exceedingly efficient at performing the SHA-256 hashing. ASICs (Application Specific Integrated Chips) became the norm for mining in 2014 and outcompete all other forms of hardware in terms of energy efficiency for Bitcoin mining. In the popular media, the computational power of these specially designed chips is often compared to the computational power of supercomputers, but ACICs cannot operate as general-purpose computers, so comparisons with supercomputers are meaningless. Only a few entities can mine profitably, usually using special purpose ‘mining farms’ clustered in areas of cheap electricity.

Miners use special purpose chips called ASICs that are specifically designed and built to be efficient at SHA-256 hashing. Commercial chip manufacturers have been slow to design chips  that are specifically built to be efficient at SHA-256 hashing, so demand has created an alternative specialised industry for supplying Bitcoin ASICs. The main provider of this is Bitmain, the same Chinese company who controls the top two mining pools. It has been estimated that Bitmain produces hardware that mines 70-80% of the total blocks in Bitcoin.

Bitcoin’s Ecosystem



The Bitcoin ecosystem consists of parties who perform different roles. Miners and bookkeepers focus on building and maintaining the blockchain itself. Wallets make it easy for people to use cryptocurrencies. Exchanges and cryptocurrency payment processors bridge between the fiat and crypto worlds.

While there are around 10,000 nodes who perform bookkeeping tasks and who relay transactions and blocks, they are mostly running the same software written, and therefore controlled, by a very small number of people. They are known as the ‘Bitcoin Core’ developers and the software is known as ‘Bitcoin Core’. The various versions, or implementations, that are not Bitcoin Core all have slightly different rules but are not different enough to create incompatibilities. Some, for example, may have additional flags to signal that the bookkeepers would be prepared to adopt a rule change if enough participants also signal the same intention.

Monday, February 25, 2019

What Are Bitcoins?



People refer to Bitcoin as a digital currency, virtual currency, or cryptocurrency, but it may be easier to think of it as an electronic asset. The word currency often side-tracks people when they are trying to understand Bitcoin. They get caught up trying to understand aspects of conventional currencies which do not apply to Bitcoin, for example, what backs it (nothing) and who sets the interest rate (there is none). Bitcoin is also sometimes described as a digital token, and in some respects that is accurate; but, alas, the term token is now also used to mean something more specific, so the ambiguity of this term too is best avoided.

Bitcoins are digital assets (‘coins’) whose ownership is recorded on an electronic ledger that is updated (almost) simultaneously on about 10,000 independently operated computers around the world that connect and gossip with each other. This ledger is called Bitcoin’s blockchain. Transactions that record transfer of ownership of those coins are created and validated according to a protocol - a list of rules that define how things work and which therefore govern updates to the ledger. The protocol is implemented by software - an app - that participants run on their computers. The machines running the apps are called ‘nodes’ of the network. Each node independently validates all pending transactions wherever they arise, and updates its own record of the ledger with validated blocks of confirmed transactions. Specialist nodes, called miners, bundle together valid transactions into blocks and distribute those blocks to nodes across the network.

Anyone can buy bitcoins, own them, and send them to other people. Every Bitcoin transaction is recorded and shared publicly in plain text on Bitcoin’s blockchain. Contrary to many media articles, Bitcoin’s blockchain is not encrypted. By design, everyone sees all details of all transactions. Anyone can, in theory, create bitcoins for themselves too. This is part of the block creation process, called mining.

The purpose of Bitcoin is described in its whitepaper - a short document written by a pseudonymous Satoshi Nakamoto, published in October 2008. It describes why Bitcoin exists and how it should work. It is worth reading the whitepaper in full. It is only nine pages long and available online. It sets out the purpose of Bitcoin, and how Bitcoin derives  both value and utility. For the first time in history, we have a system that can send value from A to B, without the physical movement of items or using specific third-party intermediaries. It is difficult to overstate how important a milestone this is in the evolution of payments. As generalized by cryptocurrency industry commentator Tim Swanson, Bitcoin is designed as censorship resistant digital cash. There is no mention of a blockchain or ‘block chain’ at all in the original Bitcoin whitepaper, even though we are constantly reminded by the media that Bitcoin is built on blockchain or that blockchain is the underlying technology of Bitcoin. A chain of blocks was not the purpose of Bitcoin, it is just the design that was developed to achieve the objective - the solution to the business problem.

The Bitcoin blockchain is managed by software running on computers that communicate with each other forming a network. Although multiple compatible software implementations exist, the most commonly used software is called ‘Bitcoin Core’ and source code to this software is published on GitHub. This software contains the full range of functionalities needed for the network to exist.
However, in practice, the software is usually only used for its bookkeeping function.

To understand how Bitcoin works, and why it works the way it does, it is important to keep in mind the objective: to create an electronic payment system that cannot be censored, and to allow anyone the ability to send payments ‘directly from one party to another without going through a financial institution’.

Such a system cannot have a central administrator managing the ledger, as that administrator would be the financial institution that Bitcoin is set up to avoid. The system therefore needs to be able to be operated by anyone, without any need to identify themselves or gain permission from a gatekeeper. The moment that parties need to identify themselves, they lose privacy and are vulnerable to interference, coercion, prison, or worse. This goes for both administrators of the system and users themselves. So every single part of the solution needs to work with these constraints in mind.

Instead of names or account numbers and passwords, why not use public keys as the account number, and digital signatures instead of passwords? By using public keys as account numbers, anyone can create their own accounts with their own computer without having to ask an administrator for an account number. Remember, a public key is derived from a private key, which is a number picked at random. So you create an account by picking a random number (your private key) and doing some maths on it to get your public key. In Bitcoin and most other cryptocurrencies, account numbers are mathematically derived from public keys (not public keys themselves), and are called addresses. You can tell the world this Bitcoin address to allow people to pay to it. No one can spend anything from it unless they have the private key, which only you have. You can also create as many addresses as you want and your wallet software will manage all of them for you.

Public/private keypairs also solve the authentication problem. You don’t have to log in to prove that you are the account holder. When sending a payment instruction you digitally sign the transaction with your private key, and this signature proves to the administrator that the instruction is indeed coming from you, the account holder. You can create and sign the transaction offline without being connected to any network. When you broadcast the signed transaction to the administrator, all the
administrator has to do is check that the digital signature is valid for the respective account number, rather than maintain a list of usernames and passwords for you and all transacting parties.

In Bitcoin, any individual with a computer, adequate storage, and access to internet bandwidth can download some software (or write their own), connect to a few neighbors, and become a bookkeeper. New transactions are broadcast to all bookkeepers via a gossip network, and each bookkeeper relays new transactions to as many others as they are connected to. This ensures eventual propagation of transactions to all bookkeepers.

Bitcoin is digital, but it works more like physical cash. With cash you open your wallet and take this specific $10 note which you received earlier and pay $8 for your coffee and expect $2 change. Bitcoin is similar: for every payment you make, you have to specify exactly which coins you are spending - that is, which specific bitcoins that you received earlier. You refer to these received bitcoins by the transaction hash that sent the coins to you. In the same way that blocks build on each other by referring to the previous block’s hash, transactions also refer to each other using a previous transaction’s hash. When you make a Bitcoin payment, you say, ‘Take this bundle of money that came in to my account in this transaction, and pay some of it to this account and return the change to me’.

Hence all bitcoins are traceable. You can see the exact composition of every lump of Bitcoin that comes into your account - what it is composed of and where it came from - and you can trace every part of that money via the previous accounts, all the way back to when it was first created in
a coinbase transaction. I say each ‘lump of money’ specifically, rather than ‘each Bitcoin,’ because
you don’t send bitcoins coin by coin, you just send a total amount. Let’s see how this works with an example.

Let’s start with an empty address and assume that you are friends with a Bitcoin miner who has just created a ‘lump’ of 12.5 BTC in a coinbase transaction when they successfully mined a block. The 12.5 BTC is like a single banknote in a physical wallet and needs to be spent in its entirety.
The miner takes pity on you because you have no bitcoins and wants to give you 1 BTC. So the miner creates a transaction spending those 12.5 BTC to two recipients: 1 BTC to you, and 11.5 BTC back to herself. You now have a 1 BTC ‘lump’ in your account.

Now it is your lucky day and a few other people give you BTC. In further separate transactions, you receive ‘lumps’ of 2 BTC and 3 BTC. So now you have 6 BTC in your wallet, in three lumps: 1 BTC, 2 BTC, and 3 BTC. Most people think in terms of ‘account balances’ (i.e., my account goes up and down) whereas Bitcoin ‘thinks’ in transactions (the transaction spends this money and puts it there). The lumps are the result or output of a transaction, and they are unspent because you haven’t spent them yet.

The transaction is created and signed by the sender using their private keys. This signed transaction is then sent to a node (bookkeeper) who validates it according to business rules (e.g., Does this UTXO - Unspent Transaction Outputs - exist? Has it been spent before?) and technical rules (e.g., How much data does the transaction contain? Is the digital signature valid?), and if found to be valid, the bookkeeper keeps this transaction in a pool of ‘unconfirmed transactions’ that they have heard about, called a mempool or memory pool. They then propagate this transaction to their neighbors in the network. Each neighbor follows the same process. Eventually a miner or block-creator picks up this transaction and decides whether they want to pack it into a block, and if so, they start mining the block. If the miner is successful in mining the block, they propagate the block to other miners and bookkeepers and each node records this transaction as confirmed in a block.

When people say Bitcoin is ‘peer-to-peer’ what do they mean? Firstly, data is sent between bookkeepers in a peer-to-peer way, i.e., directly and not via a central server. Transactions and blocks are sent between bookkeepers who are each as important in status as each  other - that is, they are peers. They use the internet to send data between themselves, instead of a 3rd party infrastructure like the SWIFT network used by major banks.

Second, Bitcoin payments are often described as peer-to-peer (i.e., with no middle man). But is this really true? Up to a point. A physical cash transaction is definitely peer-to-peer as there are no other actors other than the payer and the recipient. But Bitcoin also has intermediaries such as miners and bookkeepers. The difference between Bitcoin payments and bank payments is that, with Bitcoin payments, the intermediaries are non-specific and can act in lieu of each other, whereas traditional banks and centralised payment services are specific intermediaries. For example, if you have an account with HSBC you can’t instruct another bank such as Citibank to move your money, but in Bitcoin any miner can add your transaction to a block they are mining.

Peer-to-peer models of data distribution are like a gossip network where each peer shares updates. Peer-to-peer is in many ways less efficient than client-server, as data is replicated and validated many times, once per machine, and each change to the data creates a lot of noisy gossip. However, each peer is independent and the network can continue operating if some nodes temporarily lose connectivity. And because there is no central server that can be controlled, peer-to-peer networks are more robust and resistant to shutdown, whether accidental or deliberate.

In anonymous, and therefore untrusted, peer-to-peer networks, each peer needs to operate on the basis that any other peer could be a bad actor. So every peer needs to do their own homework and validate transactions and blocks, rather than trusting other peers. The network as a whole acts honestly, if populated by a majority of honest nodes.

What can and can’t miscreants do? The impact of a malicious bookkeeper is very limited. They can withhold transactions and refuse to pass them to other bookkeepers, or they can present a false view of the state of the blockchain to anyone asking them. A quick check with other bookkeepers will reveal any discrepancies. So the impact of a malicious miner is also actually quite limited.
Furthermore, a miner discovered to be enabling double spends could quickly find themselves cut off from the rest of the network if the rest of the network informally agrees to take action. Honest miners might agree not to build on blocks generated by a malicious miner.

Transactions are payment instructions of specific amounts of Bitcoin (UTXOs) from one
user-generated account (address) to another. The transactions are created using wallet software, authenticated with unique digital signatures, then sent to bookkeepers (nodes) who individually
validate them according to some well-known business and technical rules. The bookkeepers then add valid transactions to their mempool and distribute them to other bookkeepers that they are connected to.

Miners gather these individual transactions into blocks and compete with each other to mine their blocks by tweaking the block contents, specifically the nonce field, until the hash of the block is smaller than some target number. The target number is based on the difficulty setting at the time, which is derived from the time taken to mine the previous set of blocks to achieve a network-wide target frequency of one new mined block every 10 minutes. Miners receive a financial incentive in the form of new BTC and transaction fees which they may credit themselves, to compensate for spending resources to perform the competitive, repetitive hashing needed to create valid blocks.

The blocks link to each other in a unique sequence to form a ledger, the Bitcoin blockchain, that is recorded identically almost simultaneously on thousands of computers around the world that run Bitcoin software. If a Bitcoin transaction is not recorded on this blockchain, it is not a Bitcoin
transaction. It doesn’t exist. A Bitcoin transaction recorded outside this file does not form part of the ledger. There is no central authority who controls the ledger or who can censor specific transactions. Different blockchain platforms or systems work differently. If you relax or change the aims or constraints, the design of the solution can also change.

Tuesday, February 19, 2019

How is Ethereum Different from Bitcoin?



When you download and run the Ethereum software, it creates and starts a segregated virtual computer on your machine called an ‘Ethereum Virtual Machine’ (EVM). This EVM processes all the Ethereum transactions and blocks, and keeps track of all the account balances and results of the smart contracts. Each node on the Ethereum network runs the same EVM and processes the same data, resulting in them all having the same view of the world. Ethereum can be described as a replicated state machine because all of the nodes running Ethereum are coming to consensus about the state of the Ethereum Virtual Machine.

Compared with Bitcoin’s primitive scripting language, the code that can be deployed in Ethereum and run as smart contracts is more advanced and approachable for developers. You can think of smart contracts as pieces of code run by all the nodes in Ethereum’s Virtual Machine. In Bitcoin, you can add a small amount of BTC as a transaction fee that goes to the miner who successfully mines the block. This compensates the miner for checking the validity of the transaction and including it in the block they are mining. Likewise, in Ethereum, you can add a small amount of ETH as a mining fee which goes to the miner who successfully mines the block.

The complication with Ethereum is that there are more types of transactions. Different transaction types have different computational complexities. For example, a transaction performing a simple ETH payment is less complex than a transaction to upload or run a smart contract. Therefore, Ethereum has a concept of ‘gas’ which is a sort of price list, based on the computational complexity of the different types of operation you are instructing the miners to make in your transaction.
Operations include searching for data, retrieving it, making calculations, storing data, and making changes to the ledger.

A basic transfer of ETH from one account to another uses 21,000 gas. Uploading and running smart contracts uses more gas depending on their complexity. When you submit an Ethereum transaction, you specify a gas price (how much ETH you are willing to pay per gas used) and a gas limit (the maximum amount of gas you will let the transaction use). Mining fee (in ETH) = gas price (in ETH per gas) x gas consumed (in gas). The gas price is the amount of ETH you are prepared to pay per unit of gas for the transaction to be processed. As with Bitcoin transaction fees, this is a competitive market, and in general the busier the network the higher the gas price people are willing to pay. In times of great demand gas, prices spike.

The gas limit you set provides a ceiling for how much gas you are prepared for a transaction to consume. This limit protects you from over-spending  on mining fees and you know that the maximum mining fee will be gas limit x gas price. This stops you over-paying if you accidentally
submitted a very complex transaction that you thought was simple.

Analogy time: driving your car 10km will use up a certain amount of fuel. If you run out of fuel, your car will stop before reaching the destination. The price of fuel is dependent on market conditions and can go up and down, but the price of fuel bears no relation to how far you may drive your car with it. Gas in Ethereum is similar. When you submit an Ethereum transaction, you specify how much gas you’re prepared to spend on making the transaction ‘work’ (this is the gas limit), and how much ETH you are prepared to pay the miner per unit of gas (this is the gas price). This results in a total amount of ETH you’re prepared to pay for the transaction to be processed.

The miner will execute the transaction and will charge you the amount of gas taken, multiplied by the gas price you specified. As with Bitcoin, the mining fee is up to you, and you need to bear in mind that you’re competing with other transactions which may have set a higher gas price. For example, a basic transaction of a transfer of ETH from one account to another uses 21,000 gas, so you can set the gas limit for this kind of transaction to 21,000, or higher; but it will only use 21,000 gas. If you set the gas limit below the amount of gas it takes to process the transaction, the transaction will fail and you will not be refunded your mining fee. This is like trying to make a journey with insufficient fuel in your tank; the fuel will be used, but you will not get to your destination.

Just like one dollar can be split into 100 cents, 1 BTC can be split into 100,000,000 Satoshi, and Ethereum too has its own unit naming convention. The smallest unit is a Wei and there are
1,000,000,000,000,000,000 of them per ETH. There are also some other intermediate names:
Finney, Szabo, Shannon, Lovelace, Babbage, Ada - all named after people who made significant contributions to fields related to cryptocurrencies or networks. Wei and Ether are the two most common denominations. Wei is usually used for gas price (a gas price of 2-50 Giga-Wei per gas is common, where 1 GWei is 1,000,000,000 Wei).

In Ethereum the time between blocks is around 14 seconds, compared with Bitcoin’s ~10 minutes. This means that, on average, if you made a Bitcoin transaction and an Ethereum transaction, the Ethereum transaction would be recorded into Ethereum’s blockchain faster than the Bitcoin transaction into Bitcoin’s blockchain. You could say Bitcoin writes to its database roughly every 10 minutes, whereas Ethereum writes to its database roughly every 14 seconds.

Currently, Bitcoin’s blocks are a little under 1MB in size whereas most Ethereum blocks are about 15-20kb in size. However, we should not compare blocks by the amount of data in them: while Bitcoin’s maximum block size is specified in bytes, Ethereum’s block size is based on complexity of contracts being run. It is known as a gas limit per block, and the maximum is allowed to vary slightly from block to block. So whereas Bitcoin’s block size limit is based on amount of data,
Ethereum’s block size limit is based on computational complexity.

Currently, the maximum block size in Ethereum is around 8 million gas. Basic transactions, or payments of ETH from one account to another (i.e., uploading or invoking a smart contract), have a complexity of 21,000 gas; so you can fit around 380 of those basic transactions into a block
(8,000,000 / 21,000). In Bitcoin, you currently get around 1,500-2,000 basic transactions in a 1MB block.

Because Ethereum’s rate of block generation is much higher than Bitcoin’s (250 blocks per hour on Ethereum vs six blocks per hour on Bitcoin), the rate of ‘block clashes’ increases. Multiple valid blocks can get created at almost the same time, but only one of them can make it into the main chain. The other one ‘loses,’ and the data in them is not considered part of the main ledger, even if the transactions are technically valid.

In Bitcoin, these non-mainchain blocks are called orphans, or orphaned blocks, and they do not form part of the main chain in any way and are never referenced again by any subsequent blocks. In Ethereum they are called uncles. Uncles can be referenced by a few of the subsequent blocks and although the data in them is not used, the slightly smaller reward for mining them is still valid.
Transactions that end up in orphaned blocks simply end up being remined on the main chain. They don’t cost the user any more gas, because the transaction in the orphaned block is treated as if it was never processed.

How is Ethereum Similar to Bitcoin?



Ethereum’s token is called Ether, shortened to ETH. This is a cryptocurrency that can be traded for other cryptocurrencies or other sovereign currencies, just like BTC. ETH ownership is tracked on
the Ethereum blockchain, just like BTC ownership is tracked on Bitcoin’s blockchain.

Like Bitcoin, Ethereum has a blockchain, which contains blocks of data (pure ETH payments as well as smart contracts). The blocks are mined by some participants and distributed to other participants who validate them. You can explore this blockchain on etherscan.io. Like Bitcoin, Ethereum blocks form a chain by referring to the hash of the previous block.

Like Bitcoin, the main Ethereum network is a public, permissionless network. Anyone can download or write some software to connect to the network and start creating transactions and smart contracts, validating them, and mining blocks without needing to log in or sign up with any other organisation.

When people talk about Ethereum they usually mean the main public permissionless version of the network. However, like Bitcoin, you can take Ethereum software, modify it slightly, and create private networks that are not connected to the main public network. The private tokens and smart contracts won’t be compatible with the public tokens though, just like private Bitcoin networks.

Like Bitcoin, mining participants create valid blocks by spending electricity to find solutions to a mathematical challenge. Ethereum’s PoW maths challenge, called Ethash, works slightly differently from Bitcoin’s, and allows more common hardware to be used. It is deliberately designed to reduce the efficiency edge of specialised chips called ASICs, which are common in Bitcoin mining. Commodity hardware is allowed to compete efficiently, and this allows for a greater decentralisation of miners. In practice though, specialised hardware has been created and so most blocks in Ethereum are created by one of a small group of miners.

On Ethereum’s roadmap there is a plan to move from electricity-expensive, proof-of-work mining, to a more energy-efficient, proof-of-stake mining protocol called Casper in a future release of the Ethereum software called Serenity. Proof-of-stake is a mining protocol in which your chance of creating a valid block is proportional to the number of coins (ETH) in your mining wallet - contrast this to proof-of-work, where your chance of creating a valid block is proportional to the amount of
computational cycles your hardware can crunch through.

How might this impact the community? For starters, this would dramatically reduce the energy footprint of the cryptocurrency. Miners will no longer need to consume electricity competitively in order to win blocks. On the other hand, some people think that proof-of-stake is less democratic, because those who already have accumulated a lot of ETH will have a higher chance of winning more blocks. So, the argument goes, new money will flow towards the wealthy, increasing the Gini
coefficient of Ethereum holders.

There are flaws in the ‘less democratic’ argument. With proof-of-work the high capital costs and expertise required mean that only a very small minority of people can actually make money mining, so it is not actually that democratic. Whereas with proof-of-stake, every ETH has an identical
chance of winning a block, so you can get started with much less capital. Think of it as an interest rate: if you have more money you get more interest, but at least those with small amounts of money can still get interest. Reducing the negative externalities of pollution caused by proof-of-work is a decent and honourable goal.

What is Ethereum?



The vision of Ethereum is to create an unstoppable, censorship resistant, self-sustaining, decentralised, world computer. To achieve this, Ethereum builds on the concepts we saw with Bitcoin. If you consider Bitcoin as trustless validation and distributed storage of (transaction) data,
Ethereum is trustless validation and distributed storage and processing of data and logic. Ethereum has a public blockchain running on 15,000 computers and the token on the blockchain is called Ether, currently the second most popular cryptocurrency.

Like Bitcoin, Ethereum is also a bunch of protocols written out as code which is run as Ethereum software which creates Ethereum transactions containing data about Ether coins (ETH) recorded on Ethereum’s blockchain. In contrast with Bitcoin, Ethereum transactions can contain more than just payment data, and the nodes in Ethereum are capable of validating and processing much more than simple payments.

On Ethereum, you can submit transactions that create smart contracts - small bits of general purpose logic that are stored on Ethereum’s blockchain on all of the Ethereum nodes. These smart contracts can be invoked by sending Ether to them. This is a bit like deploying a juke machine, then putting coins in to play music. When a smart contract is invoked, all the Ethereum nodes run the code and update their ledgers with the results. These transactions and smart contracts are run by all participants using a sort of operating system called a ‘Ethereum Virtual Machine’.

Ethereum’s blockchain can be interrogated using websites like etherscan.io. As with Bitcoin, there are also forks of the main Ethereum, such as Ethereum Classic, which is also a public blockchain. Each fork has a separate coin (Ethereum’s coin is denoted ETH whereas Ethereum Classic’s coin is denoted ETC). The forks have a shared history with Ethereum up to a certain point in time, after which the blockchains differ. Ethereum’s code can also be run as a private network, starting a new
blockchain with limited participants.

To participate in the Ethereum network, you can download some software called an Ethereum client, or you can write some yourself if you have the patience. Just like BitTorrent or Bitcoin, the Ethereum client will connect over the internet to other people’s computers running similar client software and start downloading the Ethereum blockchain from them to catch up with the latest state of the blockchain. It will also independently validate that each block conforms to the Ethereum protocol rules.

What does the Ethereum client software do? You can use it to: connect to the Ethereum network;
validate transactions and blocks; create new transactions and smart contracts; run smart contracts; mine for new blocks. Your computer becomes a ‘node’ on the network, running an Ethereum Virtual Machine, and behaves equivalently to all the other nodes. Remember in a peer-to-peer network there is no ‘master’ server and each computer is equivalent in status to any other.

Thursday, February 14, 2019

What is Blockchain Technology?



You will see the phrase ‘blockchain technology,’ or commonly just ‘blockchain,’ in many different contexts, and it can be confusing because different people use the words to mean different things.
ETH is the Ethereum blockchain, a reference to the public Ethereum transaction database - but you can also create private Ethereum blockchains by simply running some node software on some
machines and having them connect to each other. Your private Ethereum network will create its own blockchain, and the miners will mine ETH just like in the public network. Your private ETH will not be compatible with the public ETH because your private Ethereum network has a different history from the public version.

All blockchains are distributed ledgers, but you can have distributed ledgers that don’t have blocks of data chained together and broadcast to all participants. Blockchain technologies are the rules or standards for how a ledger is created and maintained. Different technologies have different rules for participation, different network rules, different specifications for how to create transactions, different methods of storing data, and different consensus mechanisms. When a network is created, the blockchain or ledger of record is initially empty of transactions.

Some example blockchain technologies are: Bitcoin, Ethereum, NXT, Corda, Fabric, and Quorum.
Some blockchain technologies operate one way, others operate a slightly different way and you can have multiple instances of any blockchain technology, in separate ledgers.

Tuesday, February 12, 2019

Notable Cryptocurrencies and Tokens



There are many cryptocurrencies that either exist as blockchains in themselves or as tokens recorded in smart contracts on other blockchains, usually on Ethereum’s public chain. Onchainfx.com and Coinmarketcap.com do a good job in cataloguing these if they trade over a certain amount of volume per day.

Currency tokens (Primarily used as Money/Store of Value):
• Bitcoin (BTC) - the original cryptocurrency and store of value, created by pseudonymous Satoshi Nakamoto, launched in 2009.
• Ripple (XRP) - a token used to move value across the Ripple network, designed as a currency that was initially described to compete against banks then to be used by banks to improve foreign exchange and international payments. Created in 2012 by OpenCoin (rebranded to Ripple Inc in 2015).
• Litecoin (LTC) - an early Bitcoin clone with faster blocks and a different mining proof-of-work. Called ‘Silver to Bitcoin’s Gold’ by its founder Charlie Lee who announced that he sold all of his Litecoin in Dec 2017.
• Zcash (ZEC) - a privacy focused coin using advanced cryptography called zero knowledge proofs to shield transaction data. Created by Zooko Wilcox-O’Hearn in 2016.
• Dash (DASH) - another privacy focused coin, created as XCoin in 2014 by Evan Duffield, renamed Darkcoin, renamed DASH.
• Monero (XMR) - yet another privacy focused coin, uses ring-signatures to obscure payer and recipient addresses. Launched in 2014.

Platform tokens (i.e. those used as gas to power smart contracts):
• Ethereum (ETH) - the original smart contract enabled blockchain platform, created by a Vitalik Buterin and launched in 2015.
• Ethereum Classic (ETC) - fork of Ethereum which didn’t bail out DAO investors. Proponents like immutability. Forked from Ethereum in July 2016.
• New Economy Movement (NEM) - a blockchain with ‘smart assets’.
• EOS (EOS) - a new blockchain structure designed to be more scalable than Ethereum.

Utility tokens (Built for Specific-Use Networks):
• Augur (REP) - a token used for betting on things on a ‘prediction market,’ i.e. a betting platform. Launched in 2015 from San Francisco.
• Siacoin (SC) - a token used for paying for encrypted decentralised file storage. Launched in 2015.
• Golem (GNT) - a token used for paying for decentralised computations & calculations. Launched in 2016.
• Gnosis (GNO) - another prediction market coin. Launched in 2016 from Germany.

Brand tokens (Specific-Use on Single Entity’s Network):
• Basic Attention Token (BAT) - Token used to make micropayments in a web browser called Brave. Launched in 2017.
• Civic (CVC) - Something to do with identity verification on the blockchain. I hope it solves the problem of having too many passwords. Launched in 2017.
• Steem (STEEM) - Token used for making micropayments on social media and forum sites. Launched in 2016.

This is just a short list of the many tokens and platforms that exist today.