以太坊 智能合约
Ethereum is a decentralized computing platform. It generates a crytocurrency token known as Ether. Programmers can write “smart contracts” on the Ethereum blockchain, and these contracts are automatically executed according to their code.
以太坊是一个去中心化的计算平台。 它生成一个称为Ether的低温货币令牌。 程序员可以在以太坊区块链上写“智能合约”,这些合约会根据他们的代码自动执行。
什么是以太坊? (What is Ethereum?)
Ethereum is often mentioned in the same breath as Bitcoin, but it’s rather different. Bitcoin is a cryptocurrency and decentralized payment network that allows Bitcoin tokens to be transferred between users.
以太坊与比特币经常被同时提及,但是却大不相同。 比特币是一种加密货币和去中心化的支付网络,它允许在用户之间转移比特币令牌。
The Ethereum project has larger goals. As the Ethereum website puts it, “Ethereum is a decentralized platform that runs smart contracts.” These contracts run on the “Ethereum Virtual Machine,” a distributed computing network made up of all the devices running Ethereum nodes.
以太坊项目有更大的目标。 正如以太坊网站所说,“以太坊是一个运行智能合约的去中心化平台。” 这些合同在“以太坊虚拟机”上运行,这是一个由运行以太坊节点的所有设备组成的分布式计算网络。
The “decentralized platform” part means that anyone can set up and run an Ethereum node, the same way anyone can run a Bitcoin node. Anyone who wants to run a “smart contract” on the nodes has to pay the operators of those nodes in Ether, which is a cryptocurrency token tied to Ethereum. Thus, people who run Ether nodes provide computing power and are paid in Ether, in a similar way to how people who run Bitcoin nodes provide hashing power and are paid in Bitcoin.
“去中心化平台”部分意味着任何人都可以设置和运行以太坊节点,就像任何人都可以运行比特币节点一样。 任何想要在节点上运行“智能合约”的人都必须向以太坊中那些节点的运营商付款,这是与以太坊相关的加密货币令牌。 因此,运行以太节点的人提供计算能力并在以太币中付款,类似于运行比特币节点的人提供散列能力并以比特币来付款。
In other words, while Bitcoin is just a blockchain and payment network, Ethereum is a distributed computing network with a blockchain that can be used for many other things. Detailed information is available in the Ethereum white paper.
换句话说,虽然比特币只是一个区块链和支付网络,但以太坊是一个分布式计算网络,具有一个可以用于许多其他事情的区块链。 以太坊白皮书中提供了详细信息。
什么是醚? (What is Ether?)
Ether is the digital token (or cryptocurrency) associated with the Ethereum blockchain. In other words, Ether is the coin and Ethereum is the platform. However, people now often use these terms interchangeably. For example, Coinbase allows you to buy Ethereum—by which it means Ether tokens.
以太是与以太坊区块链关联的数字令牌(或加密货币)。 换句话说,以太币是硬币,以太坊是平台。 但是,人们现在经常可以互换使用这些术语。 例如, Coinbase允许您购买以太坊,即以太币。
This is technically “altcoin,” which really just means a non-Bitcoin cryptocurrency. Like Bitcoin, Ether is backed by a decentralized blockchain—in this case, the Ethereum blockchain.
从技术上讲,这是“ altcoin ”,实际上仅表示非比特币加密货币。 像比特币一样,以太币由分散的区块链支持-在这种情况下,以太坊区块链。
Developers who want to create apps, or “smart contracts,” on the Ethereum blockchain need the Ether token to pay nodes to host it, while users of Ethereum-based apps may need Ether to pay for services in those apps. People could also sell services outside the Ethereum network and accept payment in Ether, or Ether tokens could be sold for cash on an exchange—just like Bitcoin.
想要在以太坊区块链上创建应用程序或“智能合约”的开发人员需要以太币以支付节点来托管它,而基于以太坊的应用程序的用户可能需要以太币来支付这些应用程序中的服务。 人们还可以在以太坊网络之外出售服务并接受以太币的付款,或者可以在交易所中以现金出售以太币,就像比特币一样。
为什么分散式应用程序很有趣? (Why Are Decentralized Applications Interesting?)
The Bitcoin blockchain stores a history of Bitcoin transactions, and that’s it. The Ethereum blockchain stores the Ether tokens in people’s wallets, but it also stores the most recent state of each smart contract as well as each smart contract’s code.
比特币区块链存储着比特币交易的历史,仅此而已。 以太坊区块链将以太币存储在人们的钱包中,但它还存储了每个智能合约的最新状态以及每个智能合约的代码。
A blockchain is a distributed ledger stored in multiple locations, so this means that the smart contract data is stored by those Ethereum nodes. If you create a “smart contract”—also known as an application—on the blockchain, it’s stored and run in a decentralized manner.
区块链是存储在多个位置的分布式账本,因此这意味着智能合约数据由那些以太坊节点存储。 如果您在区块链上创建“智能合约”(也称为应用程序),则它将以分散的方式存储和运行。
For comparison, think of many of the applications we use today. This includes email apps like Gmail, note-taking apps like Microsoft OneNote, and anything else where you use an app and store your data on a company’s servers. If the company storing your data bans your accounts, shuts down the app, or goes out of business, you’d lose all the data you had in that app unless you had an offline backup copy.
为了进行比较,请考虑一下我们今天使用的许多应用程序。 这包括电子邮件应用程序(例如Gmail),笔记记录应用程序(例如Microsoft OneNote)以及您使用应用程序并将数据存储在公司服务器上的其他任何应用程序。 如果存储数据的公司禁止您的帐户,关闭该应用程序或倒闭,除非拥有离线备份副本,否则您将丢失该应用程序中拥有的所有数据。
If you were using an app built on top of Ethereum, both the code that makes up the app (the smart contract code) and personal data (the state of the smart contract) would be stored on the blockchain. Whenever you used an app and changed your data, all the Ethereum nodes would update the state of the smart contract. This means that there’s no central “point of failure” that could take away your access to the data or shut down the app you use. Your data and the app’s code itself would be backed up all over the world, and no one could take all those notes offline. Of course, your data would be encrypted by the blockchain so no one else could read it.
如果您使用的是构建在以太坊之上的应用程序,那么组成该应用程序的代码(智能合约代码)和个人数据(智能合约的状态)都将存储在区块链上。 每当您使用应用程序并更改数据时,所有以太坊节点都会更新智能合约的状态。 这意味着没有中央“故障点”会夺走您对数据的访问或关闭您使用的应用程序。 您的数据和应用程序代码本身将在世界范围内备份,没有人可以将所有这些注释脱机。 当然,您的数据将由区块链加密,因此没有其他人可以读取它。
什么是智能合约? (What Are Smart Contracts?)
Smart contracts are applications that run on the Ethereum Virtual Machine. This is a decentralized “world computer” where the computing power is provided by all those Ethereum nodes. Any nodes providing computing power are paid for that resource in Ether tokens.
智能合约是在以太坊虚拟机上运行的应用程序。 这是一个分散的“世界计算机”,其中所有这些以太坊节点都提供了计算能力。 任何提供计算能力的节点都将以以太网令牌为该资源付费。
They’re named smart contracts because you can write “contracts” that are automatically executed when the requirements are met.
它们之所以称为智能合约,是因为您可以编写“合约”,这些合约在满足要求时会自动执行。
For example, imagine building a Kickstarter-like crowdfunding service on top of Ethereum. Someone could set up an Ethereum smart contract that would pool money to be sent to someone else. The smart contract could be written to say that when $100,000 of currency is added to the pool, it will all be sent to the recipient. Or, if the $100,000 threshold hasn’t been met within a month, all the currency will be sent back to the original holders of the currency. Of course, this would use Ether tokens instead of US dollars.
例如,假设在以太坊之上构建类似于Kickstarter的众筹服务。 有人可以建立一个以太坊智能合约,该合约将汇出的钱汇给其他人。 可以将智能合约写为说,当向池中添加100,000美元的货币时,它将全部发送给接收者。 或者,如果在一个月内未达到100,000美元的门槛,则所有货币都将退还给该货币的原始持有者。 当然,这将使用以太币而不是美元。
This all would happen according to the smart contract code, which automatically executes the transactions without the need for a trusted third party to hold the money and sign off on the transaction. For example, Kickstarter takes a 5% fee on top of a 3% to 5% payment processing fee, which would mean $8000 to $10000 in fees on a $100,000 crowdfunding project. A smart contract wouldn’t require paying fees to a third-party like Kickstarter.
所有这一切都将根据智能合约代码发生,该合约代码将自动执行交易,而无需受信任的第三方持有资金并签下交易。 例如,Kickstarter在收取3%至5%的付款处理费的基础上收取5%的费用,这意味着在100,000美元的众筹项目中将收取8000至10000美元的费用。 智能合约不需要向Kickstarter这样的第三方支付费用。
Smart contracts can be used for many different things. Developers can create smart contracts that provide features to other smart contracts, similar to how software libraries work. Or smart contracts could simply be used as an application to store information on the Ethereum blockchain.
智能合约可以用于许多不同的事物。 开发人员可以创建智能合约,为其他智能合约提供功能,类似于软件库的工作方式。 或者智能合约可以简单地用作在以太坊区块链上存储信息的应用程序。
To actually execute smart contract code, someone has to send enough Ether as a transaction fee—how much depends on the computing resources required. This pays the Ethereum nodes for participating and providing their computing power.
要实际执行智能合约代码,某人必须发送足够的以太币作为交易费用,多少取决于所需的计算资源。 这使以太坊节点参与并提供其计算能力而付费。
CryptoKitties使用智能合约 (CryptoKitties Use Smart Contracts)
One of the most well-known applications built using smart contracts on the Ethereum network is CryptoKitties, which bills itself as “one of the worlds’ first games to be built on blockchain technology.”
使用以太坊网络上的智能合约构建的最著名的应用程序之一是CryptoKitties ,它自称为“世界上第一个基于区块链技术构建的游戏之一”。
Essentially, CryptoKitties are a form of digital “collectible” stored on the Ethereum blockchain. CryptoKitties provides a good demonstration of the ability to store and exchange digital items on the Ethereum network.
从本质上讲,CryptoKitties是存储在以太坊区块链上的一种数字“收藏品”。 CryptoKitties很好地展示了在以太坊网络上存储和交换数字商品的能力。
New CryptoKitties are generated through “breeding.” This involves choosing two base CryptoKitties and spending Ether tokens to run a smart contract. The contracts use the two chosen cats to spawn a new CryptoKitty. These kitties and the details of the breeding process are stored on the Ethereum blockchain’s public ledger.
新的CryptoKitty是通过“繁殖”产生的。 这涉及选择两个基本的CryptoKitties,并花费以太币令牌来运行智能合约。 合同使用两只选择的猫来生成新的CryptoKitty。 这些小猫和繁殖过程的详细信息存储在以太坊区块链的公共分类账中。
You can “own” CryptoKitties, which are stored on the Ethereum blockchain ledger. You can sell or trade them to other people, or buy them. This is different from using a smartphone app that allows you to buy, trade, and breed cats. Those will generally be stored on the app’s own servers, and you could lose your precious digital pets if the company shut down the app or banned your account. But, because CryptoKitties are stored on the blockchain, that can’t happen. No one can take your kitties away from you.
您可以“拥有”存储在以太坊区块链分类账中的CryptoKitties。 您可以将它们出售或交易给其他人,也可以购买。 这与使用允许您购买,交易和繁殖猫的智能手机应用程序不同。 这些通常会存储在应用程序自己的服务器上,如果公司关闭该应用程序或禁止您的帐户,您可能会失去珍贵的数字宠物。 但是,因为CryptoKitties存储在区块链上,所以不会发生这种情况。 没有人可以把你的小猫带走。
In December 2017—coincidentally, around Bitcoin’s all-time high prices—people had spent the Ether equivalent of more than $12 million on CryptoKitties, and the most expensive CryptoKitty was sold for around $120,000.
2017年12月,巧合的是,围绕比特币的历史最高价,人们在CryptoKitties上花费了相当于1200万美元的以太币,最昂贵的CryptoKitty售价约为12万美元。
Like Ether, Bitcoin, and expensive paintings, CryptoKitties are worth whatever people are prepared to pay for them.
像以太币,比特币和昂贵的画作一样,CryptoKitties值得人们准备为此支付。
Image Credit: AlekseyIvanov/Shutterstock.com, Ethereum, CryptoKitties.
图片来源: AlekseyIvanov / Shutterstock.com,以太坊, CryptoKitties 。
翻译自: https://www.howtogeek.com/350322/what-is-ethereum-and-what-are-smart-contracts/
以太坊 智能合约