Python Blockchain 简明教程
Python Blockchain - Introduction
在区块链教程中,我们详细学习了区块链背后的理论知识。区块链是支撑全球最流行的数字货币 Bitcoin 的基石。本教程深入探讨了 Bitcoin 的复杂性,并全面解释了区块链架构。下一步是构建我们自己的区块链。
In the tutorial on Blockchain, we have learnt in detail about the theory behind blockchain. The blockchain is the fundamental building block behind the world’s most popular digital currency Bitcoin. The tutorial deeply dealt with the intricacies of Bitcoin explaining fully the blockchain architecture. The next step is to build our own blockchain.
中本聪创造了世界上第一个名为 Bitcoin 的虚拟货币。受 Bitcoin 成功的影响,许多其他人创建了自己的虚拟货币。举几个例子:莱特币、Zcash 等。
Satoshi Nakamoto created the first virtual currency in the world called Bitcoin. Looking at the success of Bitcoin, many others created their own virtual currencies. To name a few − Litecoin, Zcash, and so on.
现在,您可能也想发行自己的货币。我们将此称为 TPCoin(TutorialsPoint 硬币)。您将编写一个区块链来记录所有涉及 TPCoin 的交易。TPCoin 可用于购买比萨饼、汉堡、沙拉等。可能还有其他服务提供商加入您的网络,并开始接受 TPCoin 作为提供其服务的货币。可能性是无穷无尽的。
Now, you may also like to launch your own currency. Let us call this as TPCoin (TutorialsPoint Coin). You will write a blockchain to record all transactions that deal with TPCoin. The TPCoin can be used for buying Pizzas, Burgers, Salads, etc. There may be other service providers who would join your network and start accepting TPCoin as the currency for giving out their services. The possibilities are endless.
在本教程中,让我们了解如何构建这样一个系统并在市场上发行您自己的数字货币。
In this tutorial, let us understand how to construct such a system and launch your own digital currency in the market.
Components Involved in Blockchain Project Development
整个区块链项目开发包括三个主要部分 -
The entire blockchain project development consists of three major components −
-
Client
-
Miners
-
Blockchain
Client
客户是指从其他供应商处购买商品的人。客户自己可能会成为一个供应商,并会收取他人对其提供的商品的钱。我们在此假定客户既可以是 TPCoin 的供应商,也可以是接收者。因此,我们将在我们的代码中创建一个客户端类,该类具有发送和接收货币的能力。
The Client is the one who will buy goods from other vendors. The client himself may become a vendor and will accept money from others against the goods he supplies. We assume here that the client can both be a supplier and a recipient of TPCoins. Thus, we will create a client class in our code that has the ability to send and receive money.
Miner
矿工是指从交易池中提取交易并将它们组装到一个块中的人。矿工必须提供有效的功耗证明才能获得挖矿奖励。矿工收取的所有费用都归他所有。他可以用这笔钱从网络上其他注册的供应商处购买商品或服务,就像上面描述的客户一样。
The Miner is the one who picks up the transactions from a transaction pool and assembles them in a block. The miner has to provide a valid proof-of-work to get the mining reward. All the money that miner collects as a fee will be for him to keep. He may spend that money on buying goods or services from other registered vendors on the network, just the way a Client described above does.
Blockchain
最后,区块链是一个数据结构,按时间顺序链接所有已挖掘的块。此链是不可变的,因此是防篡改的。
Finally, a Blockchain is a data structure that chains all the mined blocks in a chronological order. This chain is immutable and thus temper-proof.
您可以通过在新的 Jupyter 笔记本中键入每一步中提供的代码来遵循本教程。或者,您可以从 www.anaconda.com 下载整个 Jupyter 笔记本。
You may follow this tutorial by typing out the code presented in each step in a new Jupyter notebook. Alternatively, you may download the entire Jupyter notebook from www.anaconda.com.
在下一章中,我们将开发一个使用我们区块链系统的客户端。
In the next chapter, we will develop a client that uses our blockchain system.