Decentralized Applications: Harnessing Bitcoin's Blockchain Technology
Rate it:
Open Preview
4%
Flag icon
Bitcoin and other cryptocurrencies will help define the fifth protocol layer of the Internet, letting machines transfer value as fast and efficiently as data.
4%
Flag icon
consensus mechanism called proof-of-work which prevents double-spending in the network
4%
Flag icon
with proof-of-work, they would also need to have the majority of computational power in the network to verify it.
5%
Flag icon
Distributed means computation is spread across multiple nodes instead of just one. Decentralized means no node is instructing any other node as to what to do.
5%
Flag icon
Bitcoin is distributed because its timestamped public ledger, the blockchain, resides on multiple computers. It’s also decentralized because if one node fails, the network is still able to operate.
6%
Flag icon
Decentralized, closed-source applications require users to trust that the app is as decentralized as the core developers say it is, and that they don’t have access to their data through a central source.
6%
Flag icon
How is any open-source dapp developer supposed to make money? The answer is to allocate scarce resources in the network using a scarce token: an appcoin. Users need this appcoin to use the network. Owners of scarce resources get paid in appcoins.
7%
Flag icon
The blockchain’s innovation is decentralized consensus. If your app needs some feature that requires everyone else to agree on something, you should use a blockchain.
7%
Flag icon
The blockchain is an immutable record that every node has a copy of, so no one can pretend that they too are @user. This can be done via the use of smart contracts.
7%
Flag icon
A smart contract is a piece of code that lives in a blockchain. When a preprogrammed condition is triggered, the smart contract executes the corresponding contractual clause.
8%
Flag icon
One big difference: smart contracts live on a blockchain, not a server. No third-party trust is required, and there is no need to trust Stripe or a server owner.
11%
Flag icon
The blockchain helped solve the Byzantine Generals Problem. That problem asks the question, “How do you coordinate among distributed nodes to come up with some sort of consensus that is resistant to attackers trying to undermine it?” The proof-of-work algorithm and the blockchain help solve this.
11%
Flag icon
proof-of-work is the only known Sybil-prevention system thus far.
11%
Flag icon
In terms of up-and-coming competitors to proof-of-work, there is a big one that comes to mind: proof-of-stake. Proof-of-stake isn’t perfect, either, but it can complement proof-of-work.
11%
Flag icon
Proof-of-stake is a consensus mechanism that relies instead on computational power to prevent Sybil attacks on stake in the network. Usually, by stake it means amount of cryptocurrency owned by the miner.
13%
Flag icon
subdivide the space into three categories, following Melanie Swan’s book Blockchain (O’Reilly) and others; blockchain 1.0 is currency, blockchain 2.0 adds in contracts (stocks, bonds, financial assets), and blockchain 3.0 encompasses applications beyond pure finance in areas like governance and health (dapps).
14%
Flag icon
four concepts in web applications that have traditionally been in the domain of centralized control: identity, wealth, data,
14%
Flag icon
and computing.
16%
Flag icon
First, we don’t just want the decentralized storage capabilities of a DHT and the speed of BitTorrent’s file transfer, we also want data permanence.
16%
Flag icon
Second, we need to ensure that the links to the data don’t die.
17%
Flag icon
To be more specific, it’s a directed, acyclic graph (DAG). A merkleDAG can look like a linked list or a tree. When adding data to the DHT, the system generates an SHA-256 multihash public-private key pair, and the user gets both.
17%
Flag icon
All data on IPFS is public, so it’s the users’ responsibility to encrypt their data accordingly. The private keys, in addition to allowing access to the data, can prove ownership.
19%
Flag icon
As soon as the coin appears to have enough value, the creators sell it all for a currency that is more stable and long-term like Bitcoin or fiat. This is a common scheme in the altcoin world, and it is terrible for the cryptocurrency ecosystem for obvious reasons. First of all, these coins tarnish the reputation of
19%
Flag icon
cryptocurrency in general because they make potential investors increasingly wary of the space. Second, they compete with the Bitcoin blockchain for market share unnecessarily while bringing no real value to the table. This in turn harms Bitcoin’s value and all of those that rely on it as the most-used cryptocurrency.
22%
Flag icon
Token agnosticism is a strong set of views, but I believe Bitcoin can cooperate with existing financial systems.
26%
Flag icon
I’m willing to trust Coinbase more because it holds so many users’ assets, the CEO seems trustworthy to me (or at least much more so than Mark Karpelès of Mt Gox), and it is backed by a pair of trusted investors (Andreessen Horowitz and Union Square Ventures).
27%
Flag icon
two options. The first is to store the data in IPFS and host your source code on a traditional virtual machine (VM) for web apps like Heroku.
27%
Flag icon
A second way to deploy is by storing your users’ data on IPFS and deploying your source code to a decentralized VM built on top of IPFS. Does this exist? The closest project to achieving this is astralboot.
30%
Flag icon
In the information economy where dapps are mainstream, each user of a dapp is also consequently a shareholder.
36%
Flag icon
Centralized Architecture There are three paradigms that are commonplace when building a standard server-client–based web app. Let’s discuss them a bit. REST The server-client model is relatively simple and has become the de facto way to exchange data across the Web. REST, or Representational State Transfer, is a set of guidelines and best practices for creating scalable web apps usually based on the server-client model.
36%
Flag icon
CRUD CRUD stands for Create-Read-Update-Delete. These are the
37%
Flag icon
basic operations to be done in a data repository.
37%
Flag icon
MVC MVC stands for Model-View-Controller, and it’s currently the most popular software programming paradigm.
37%
Flag icon
what happens to CRUD and REST in a decentralized architecture? They become one and the same.
37%
Flag icon
When you build your dapp, it won’t run on a server; rather,
37%
Flag icon
it will run locally on all your users’ computers.
37%
Flag icon
web browser or directly within a client interface — for example, Spotify or Skype. Dapps will require data storage in some form or another and as such they will double as IPFS-distributed file storage nodes.
37%
Flag icon
incentivized by uploaders to store data by being paid in dollars or a cryptocurrency. IPFS creator Juan Benet published a paper for a currency called FileCoin to do just that, but work on it still hasn’t begun and thus cannot benefit us yet.
38%
Flag icon
two key commands in IPFS: ADD Add data to IPFS CAT Read data from IPFS
38%
Flag icon
add data to IPFS, you are essentially just broadcasting to the network that you have the data; you aren’t actually sending it to someone’s computer.
38%
Flag icon
IPNS (the naming layer on top of IPFS) gives the appearance that updating and deleting are possible through mutable names. With IPNS you can publish a DAG of data under your immutable peer ID,
38%
Flag icon
What about smart contracts? What role do they play? In a dapp, there are certain elements that need consensus via smart contracts that would usually require a server.
38%
Flag icon
Smart contracts are technically “models,” and you can feed data into them via transactions, but they are not the de facto “model” in MVC architecture.
39%
Flag icon
Setup Let’s set up our Go environment. I’m all about reducing complexity where it’s not necessary. Luckily, Go has package installers for Linux and Mac OS X. (Sorry, Windows users, we’re going to focus on Unix-based systems). The great thing about these package installers is that they will automatically install the Go distribution to usr/local/go and set our path variables. Path variables are one of those “gotchas” in software configuration. They link your libraries to Terminal keywords you can use to call them. If it didn’t set our path variables, we would have to set them ourselves, like so: ...more
40%
Flag icon
on the Web. To install IPFS, type this into your console: go get -d github.com/ipfs/go-ipfs After installation, Source your bash: Source ~/.bashrc
40%
Flag icon
To begin using IPFS, you need to initialize its config files on your system, as follows: 'ipfs init' This will take a few seconds; it’s adding bootstrapped (hardcoded) peers to your configuration and giving your node an identity key-pair to identify as a peer to the network when you add or pin a file.
42%
Flag icon
That data still lives on your computer, but now there is a content address associated with it, and anyone who has that address can retrieve the file directly from your computer as long as you’re online.
42%
Flag icon
Now that you’ve added some data to IPFS, let’s try CATing it back: ipfs cat <that hash> This should pull and display hello in the console. It’s pulling it directly from your computer.
42%
Flag icon
The first snippet of code starts a node, so your dapp doubles as an IPFS client. It starts up the daemon, so you broadcast yourself as a peer to the network. The second snippet of code lets you add text to IPFS. You can add any kind of data to IPFS: video, images, data structures. But
43%
Flag icon
The last snippet of text essentially performs an “ipfs cat” on the hash associated with your peerID (using IPNS) and stores it in an array for you to use and display in your view. You’ll also use a lightweight dependency called httprouter that helps making web apps easier.
« Prev 1