chaiyu2002

资讯 2024-07-09 阅读:81 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

这篇介绍以太坊合约的文章写得很好,在查找了这么多资料,进行对比之后,感觉阅读这一篇就可以大体理解以太坊编程的原理,如果对个别的知识点还有点含糊,可以相应地去查一查,就是以这篇为主干,别的资料为辅。稍微整理了一下格式,以及修改了一些半角符号。

After searching for so much information and comparing it, it was felt that reading this piece would allow for a general understanding of the principles of programming based on the Taiyeon, and if there was some ambiguity about individual knowledge points, it could be checked accordingly, with the focus on this and other information. A little formatting was done, as well as some modifications to the half corner symbols.

译注:原文首发于ConsenSys开发者博客,原作者为Eva以及ConsenSys的开发团队。如果您想要获取更多及时信息,可以访问ConsenSys首页点击左下角Newsletter订阅邮件。本文的翻译获得了ConsenSys创始人Lubin先生的授权。

: originated from the ConsenSys developer blog, originally written by Eva and ConsenSys. If you want more timely information, you can access at the beginning of the page.

有些人说以太坊太难对付,于是我们(译注:指Consensys, 下同)写了这篇文章来帮助大家学习如何利用以太坊编写智能合约和应用。这里所用到的工具,钱包,应用程序以及整个生态系统仍处于开发状态,它们将来会更好用!

Some say it's too difficult, so we write this article to help you learn how to use it to write smart contracts and applications. The tools, wallets, applications and the entire ecosystem are still in development.

  • 第一部分概述,讨论了关键概念,几大以太坊客户端以及写智能合约用到的编程语言。
  • 第二部分讨论了总体的工作流程,以及目前流行的一些DApp框架和工具。
  • 第三部分主要关于编程,我们将学习如何使用Truffle来为智能合约编写测试和构建DApp。

如果你对诸如比特币以及其工作原理等密码学货币的概念完全陌生,我们建议你先看看Andreas Antonopoulos所著的Bitcoin Book的头几章,然后读一下以太坊白皮书。(译注:以太坊白皮书中文版请看 http://ethfans.org/posts/ethereum-whitepaper)

If you are completely unfamiliar with the concept of cryptographic currency such as Bitcoin and its working principles, we suggest that you read the first chapters of and then read .

如果你觉得白皮书中的章节太晦涩,也可以直接动手来熟悉以太坊。在以太坊上做开发并不要求你理解所有那些“密码经济计算机科学”(crypto economic computer science),而白皮书的大部分是关于以太坊想对于比特币架构上的改进。

If you think the chapter in the white paper is too obscure, you can get to know Ether. Development at Etheria does not require you to understand all the “crypto economic computer science”, and most of the white paper is about the improvements that Ether wants to make to the Bitcoin architecture.

ethereum.org提供了官方的新手入门教程,以及一个代币合约和众筹合约的教程。合约语言Solidity也有官方文档。学习智能合约的另一份不错的资料(也是我的入门资料)是dappsForBeginners,不过现在可能有些过时了。

othereum.org provides an official introductory course, as well as a token contract and a public contract. The contract language is also . Another good information for learning smart contracts (also my entry information) is , although it may now be somewhat outdated.

这篇文章的目的是成为上述资料的补充,同时介绍一些基本的开发者工具,使入门以太坊,智能合约以及构建DApps(decentralized apps, 分布式应用)更加容易。我会试图按照我自己(依然是新手)的理解来解释工作流程中的每一步是在做什么,我也得到了ConsenSys酷酷的开发者们的许多帮助。

The purpose of this article is to complement the above-mentioned information by introducing some basic developers’ tools, making it easier to enter into the Etherm, to contract intelligently, and to build the Dapps (decentralized apps, distributed applications). I will try to explain what every step of the workflow is about, as I understand it, still a newcomer, and I have much help from the cool developers of ConsenSys.

了解这些名词是一个不错的开始:

Understanding these terms is a good start:

公钥加密系统。 Alice有一把公钥和一把私钥。她可以用她的私钥创建数字签名,而Bob可以用她的公钥来验证这个签名确实是用Alice的私钥创建的,也就是说,确实是Alice的签名。当你创建一个以太坊或者比特币钱包的时候,那长长的地址实质上是个公钥,对应的私钥保存某处。类似于Coinbase的在线钱包可以帮你保管私钥,你也可以自己保管。如果你弄丢了存有资金的钱包的私钥,你就等于永远失去了那笔资金,因此你最好对私钥做好备份。过来人表示:通过踩坑学习到这一点是非常痛苦的…

Public Key Encryption System. Alice has a public key and a private key. She can create a digital signature with her private key, and Bob can use her public key to verify that the signature was actually created with Alice's private key, that is to say, Alice's signature. When you create an Ethletic or Bitcoin wallet, the long address is essentially a public key, and the corresponding private key is kept somewhere. An online wallet like Coinbase can keep your private key, and you can keep it yourself. If you lose the private key to a wallet with money, you'll lose it forever, so you better back up the private key.

点对点网络。 就像BitTorrent, 以太坊分布式网络中的所有节点都地位平等,没有中心服务器。(未来会有半中心化的混合型服务出现为用户和开发者提供方便,这我们后面会讲到。)

point-to-point network. , like BitTorrent, all nodes in the Taiyo distribution network are equal and have no central servers. (There will be half-centralized hybrid services in the future to facilitate users and developers, which we will talk about later.)

区块链。 区块链就像是一个全球唯一的帐簿,或者说是数据库,记录了网络中所有交易历史。

blocks chain. blocks chain is like the only global book, or database, recording all transactions in the network.

以太坊虚拟机(EVM)。 它让你能在以太坊上写出更强大的程序(比特币上也可以写脚本程序)。它有时也用来指以太坊区块链,负责执行智能合约以及一切。

It allows you to write a stronger program (and a script program on bitcoin) at the Etheria. It is also sometimes used to refer to the Tetho block chain, which is responsible for the implementation of intelligent contracts and everything.

节点。 你可以运行节点,通过它读写以太坊区块链,也即使用以太坊虚拟机。完全节点需要下载整个区块链。轻节点仍在开发中。

Node. You can run nodes through which you can read and write in the Taiwan block chain, even if it is used as a taupe virtual machine. Full node needs to download the whole block chain. Light node is still under development.

矿工。 挖矿,也就是处理区块链上的区块的节点。这个网页可以看到当前活跃的一部分以太坊矿工:stats.ethdev.com

Miner. , which is the node for processing blocks on the block chain. This page can see the active part of the current industry: .

工作量证明。 矿工们总是在竞争解决一些数学问题。第一个解出答案的(算出下一个区块)将获得以太币作为奖励。然后所有节点都更新自己的区块链。所有想要算出下一个区块的矿工都有与其他节点保持同步,并且维护同一个区块链的动力,因此整个网络总是能达成共识。(注意:以太坊正计划转向没有矿工的权益证明系统(POS),不过那不在本文讨论范围之内。)

workload proves. miners are always competing to solve some mathematical problems. The first answer (to the next block) will be rewarded with a talisman. Then all nodes will update their block chains. All miners who want to calculate the next block are synchronized with other nodes and maintain the momentum of the same block chain, so the entire network will always be able to reach consensus. (Note: The ether is planning to move to a system of proof of interests (POS) without miners, but that is not the subject of this discussion.)

以太币。 缩写ETH。一种你可以购买和使用的真正的数字货币。这里是可以交易以太币的其中一家交易所的走势图。在写这篇文章的时候,1个以太币价值65美分。

in tae. . A true digital currency that you can buy and use. Here you can trade in one of the exchanges in tae.

Gas。(汽油) 在以太坊上执行程序以及保存数据都要消耗一定量的以太币,Gas是以太币转换而成。这个机制用来保证效率。

Gas. This mechanism is used to ensure efficiency.

DApp。 以太坊社区把基于智能合约的应用称为去中心化的应用程序(Decentralized App)。DApp的目标是(或者应该是)让你的智能合约有一个友好的界面,外加一些额外的东西,例如IPFS(可以存储和读取数据的去中心化网络,不是出自以太坊团队但有类似的精神)。DApp可以跑在一台能与以太坊节点交互的中心化服务器上,也可以跑在任意一个以太坊平等节点上。(花一分钟思考一下:与一般的网站不同,DApp不能跑在普通的服务器上。他们需要提交交易到区块链并且从区块链而不是中心化数据库读取重要数据。相对于典型的用户登录系统,用户有可能被表示成一个钱包地址而其它用户数据保存在本地。许多事情都会与目前的web应用有不同架构。)

The goal of Dapp is (or should be) to have a friendly interface to your smart contract, plus additional items such as IPFS (decentralized network that can store and read data, not from the ETA team, but a similar spirit). The Dapp can run on a centralised server that interacts with the Ether node, or on an equal node in the same room. (A moment to think: unlike a normal web site, Dapp cannot run on a normal server.) They need to submit transactions to the and from the section chain to read instead of a centralized database to read data are important.

如果想看看从另一个新手视角怎么理解这些概念,请读Just Enough Bitcoin for Ethereum

Read .

编写和部署智能合约并不要求你运行一个以太坊节点。下面有列出基于浏览器的IDE和API。但如果是为了学习的话,还是应该运行一个以太坊节点,以便理解其中的基本组件,何况运行节点也不难。

Preparing and deploying a smart contract does not require you to run an ETA node. Below is a list of based on browsers. If it is for learning, an ETA node should still be run to understand the basic components.

运行以太坊节点可用的客户端

以太坊有许多不同语言的客户端实现(即多种与以太坊网络交互的方法),包括C++, Go, Python, Java, Haskell等等。为什么需要这么多实现?不同的实现能满足不同的需求(例如Haskell实现的目标是可以被数学验证),能使以太坊更加安全,能丰富整个生态系统。

This is achieved in many different languages (i.e. through multiple ways of interacting with the Etherm network), including C++, Go, Python, Java, Haskell and so on. Why so much needs to be achieved? Different realizations that meet different needs (e.g., the goals that Haskell achieve can be mathematically validated) can make the Etherm safer and enrich the entire ecosystem.

在写作本文时,我使用的是Go语言实现的客户端geth (go-ethereum),其他时候还会使用一个叫testrpc的工具, 它使用了Python客户端pyethereum。后面的例子会用到这些工具。

At the time of writing, I used the Go language-realized client geth (go-ethereum) and at other times a tool called testrpc, which used the Python client pythereum.

注: 我曾经使用过C++的客户端,现在仍然在用其中的ethminer组件和geth配合挖矿,因此这些不同的组件是可以一起工作的。
关于挖矿:挖矿很有趣,有点像精心照料你的室内盆栽,同时又是一种了解整个系统的方法。虽然以太币现在的价格可能连电费都补不齐,但以后谁知道呢。人们正在创造许多酷酷的DApp, 可能会让以太坊越来越流行。

Note: I used the C++ client, and I'm still working with the ethminer and geth components, so these different components can work together.
About mining: mining is interesting, sort of like taking care of your indoor pot plant, but at the same time it's a way to understand the system. Although it may not even pay for electricity at the current price, who knows. People are creating a lot of cool Dapps, which may make it more popular.

交互式控制台。 客户端运行起来后,你就可以同步区块链,建立钱包,收发以太币了。使用geth的一种方式是通过Javascript控制台(JavaScript console, 类似你在chrome浏览器里面按F12出来的那个,只不过是跑在终端里)。此外还可以使用类似cURL的命令通过JSON RPC来与客户端交互。本文的目标是带大家过一边DApp开发的流程,因此这块就不多说了。但是我们应该记住这些命令行工具是调试,配置节点,以及使用钱包的利器。

Interactive Console. When the client is running, you can synchronize the block chain, build the wallet, and send it in too much currency. One way to use JavaScript Console (JavaScript console, similar to the one that you pressed F12 in the chrome browser, is just running in the terminal). The objective of this paper is also to use a similar courl order through the process developed by . The objective is to bring down Dapp's development of the process, which is therefore limited, but we should keep in mind that the tool is designed to be used.

在测试网络运行节点。 如果你在正式网络运行geth客户端,下载整个区块链与网络同步会需要相当时间。(你可以通过比较节点日志中打印的最后一个块号和stats.ethdev.com上列出的最新块来确定是否已经同步。) 另一个问题是在正式网络上跑智能合约需要实实在在的以太币。在测试网络上运行节点的话就没有这个问题。此时也不需要同步整个区块链,创建一个自己的私有链就勾了,对于开发来说更省时间。

is testing network running nodes. If you run a geth client on an official network, downloading the entire block chain to synchronise with the network will take quite some time. (You can use the last block that you print in a comparative node log and to determine whether it has been synchronized.) Another problem is that running a smart contract on a formal network requires a solid ink. There is no problem when running nodes on a network. It is also not necessary to synchronize the entire block chain at this time to create a private chain, which is more time-saving for development.

testrpc。 用geth可以创建一个测试网络,另一种更快的创建测试网络的方法是使用testrpc。Testrpc可以在启动时帮你创建一堆存有资金的测试账户。它的运行速度也更快因此更适合开发和测试。你可以从testrpc起步,然后随着合约慢慢成型,转移到geth创建的测试网络上 - 启动方法很简单,只需要指定一个networkid:。这里是testrpc的代码仓库,下文我们还会再讲到它。

testrpc. Creates a test network with geth, and a faster test network with testrpc. Testrpc can help you to create a bunch of test accounts with funds available at startup. It's also running faster and thus more suitable for development and testing. You can start from testrpc and then move to the test network created by geth as the contract is slowly shaped. - The starting method is simple, just specify a networkid. This is testrpc's code warehouse , which we will refer to later.

接下来我们来谈谈可用的编程语言,之后就可以开始真正的编程了。

Now let's talk about the available programming languages, and then we can start real programming.

写智能合约用的编程语言

用Solidity就好。 要写智能合约有好几种语言可选:有点类似Javascript的Solidity, 文件扩展名是和Python接近的Serpent, 文件名以结尾。还有类似Lisp的LLL。Serpent曾经流行过一段时间,但现在最流行而且最稳定的要算是Solidity了,因此用Solidity就好。听说你喜欢Python? 用Solidity。

uses solidity. has several options for writing smart contracts: it's sort of like Javascript, the file extension is close to Python's Serpent, and the file name ends. There's LL like Lip. Serpent used to be used for some time, but the most popular and stable is now about solidity, so it's about solidity. I hear you like Python?

solc编译器。 用Solidity写好智能合约之后,需要用solc来编译。它是一个来自C++客户端实现的组件(又一次,不同的实现产生互补),这里是安装方法。如果你不想安装solc也可以直接使用基于浏览器的编译器,例如Solidity real-time compiler或者Cosmo。后文有关编程的部分会假设你安装了solc。

Solc compiler. Writes smart contracts with Soldity, which needs to be compiled with solc. It is a component from C++ clients (and again, different realizations produce complementarities), is an installation method. If you do not want to install solc, you can also directly use browser-based compilers such as or , you are supposed to install the part of the programming.

注意:以太坊正处于积极的开发中,有时候新的版本之间会有不同步。确认你使用的是最新的dev版本,或者稳定版本。如果遇到问题可以去以太坊项目对应的Gitter聊天室或者forums.ethereum.org上问问其他人在用什么版本。

Note: Etheria is in active development, sometimes without sync with the new version. Confirm that you are using the latest dev version, or the stable version. If you have a problem, you can go to the Gitter chat room, or to ask what other people are using.

web3.js API。 当Solidity合约编译好并且发送到网络上之后,你可以使用以太坊的web3.js JavaScript API来调用它,构建能与之交互的web应用。

web3.js API. . , used by the Etherm to call it and build web applications that interact with it.

以上就是在以太坊上编写智能合约和构建与之交互的DApp所需的基本工具。

These are the basic tools needed to create a smart contract at the Etheria and to build an interactive DApp.

虽然有上文提到的工具就可以进行开发了,但是使用社区大神们创造的框架会让开发更容易。

While the tools mentioned above could be developed, the use of the framework created by the community gods would make development easier.

Truffle and Embark。Truffle把我领进了门。在Truffle出现之前的那个夏天,我目睹了一帮有天分的学生是如何不眠不休的参加一个hackathon(编程马拉松)活动的,虽然结果相当不错,但我还是吓到了。然后Truffle出现了,帮你处理掉大量无关紧要的小事情,让你可以迅速进入写代码-编译-部署-测试-打包DApp这个流程。另外一个相似的DApp构建与测试框架是Embark。我只用过Truffle, 但是两个阵营都拥有不少DApp大神。

and Embark. was Truffle led me through the door. In the summer before Truffle appeared, I saw how a group of talented students were able to stay awake and participate in a hakathon (programming marathon) activity, although , but I was still shocked.

Meteor。 许多DApp开发者使用的另一套开发栈由web3.js和Meteor组成,Meteor是一套通用webapp开发框架(ethereum-meteor-wallet项目提供了一个很棒的入门实例,而SilentCiero正在构建大量Meteor与web3.js和DApp集成的模板)。我下载并运行过一些不错的DApp是以这种方式构造的。在11月9日至13日的以太坊开发者大会DΞVCON1上将有一些有趣的讨论,是关于使用这些工具构建DApp以及相关最佳实践的(会议将会在YouTube上直播)。

Meteor. Another set of developers used by many DApp developers, consisting of web3.js and Meteor, is a universal webapp development framework (https://www.meteor.com/ >, and Dapp's "https://gethub.com/SilentCicero"repner will have a number of templates for the development of .

APIs。 BlockApps.net打算提供一套RESTful API给DApp使用以免去开发者运行本地节点的麻烦,这个中心化服务是基于以太坊Haskell实现的。这与DApp的去中心化模型背道而驰,但是在本地无法运行以太坊节点的场合非常有用,比如在你希望只有浏览器或者使用移动设备的用户也能使用你的DApp的时候。BlockApps提供了一个命令行工具bloc,注册一个开发者帐号之后就可以使用。

APIs.< intends to provide a set of RESTful APIs to DApp to avoid trouble in going to developers to run local nodes. This centralization is based on Ether Haskell's decentralisation model. This is contrary to DApp's decentralisation model, but is useful in situations where it is not possible to run a taupulega node locally, such as when you want to use your Dapp only for browsers or users using mobile devices. BlockApps has a command line tool bloc, which can be used after registering a developers account number.

许多人担心需要运行以太坊节点才能使用DApp的话会把用户吓跑,其实包括BlockApps在内的许多工具都能解决这个问题。Metamask允许你在浏览器里面使用以太坊的功能而无需节点,以太坊官方提供的AlethZero或者AlethOne是正在开发中有易用界面的客户端,ConsenSys正在打造一个轻钱包LightWallet,这些工具都会让DApp的使用变得更容易。轻客户端和水平分片(sharding)也在计划和开发之中。这是一个能进化出混合架构的P2P生态系统。

Many people fear that the need to run an admin node to use DApp will scare the user away, and many tools, including BlockApps, will solve the problem. allows you to use EEA functions in browsers without no nodes. The tools provided by Tai node are easy-to-interface clients, and ConsenSys is building a light wallet , which will make it easier for DApp to use and develop an .

IDE。 以太坊官方出品了用来编写智能合约的Mix IDE,我还没用过但会尽快一试。

IDE. .

基于浏览器的IDE。 Solidity real-time compilerCosmo都可以让你快速开始在浏览器中编写智能合约。你甚至可以让这些工具使用你的本地节点,只要让本地节点开一个端口(注意安全!这些工具站点必须可信,而且千万不要把你的全部身家放在这样一个本地节点里面!Cosmo UI上有如何使用geth做到这一点的指引)。在你的智能合约调试通过之后,可以用开发框架来给它添加用户界面和打包成DApp,这正是Truffle的工作,后面的编程章节会有详细讲解。

IDE based on browsers. Solidity real-time compiler and can get you to start writing smart contracts in browsers quickly. You can even get these tools to use your local nodes.

Ether.Camp正在开发另一个强大的企业级浏览器IDE。他们的IDE将支持沙盒测试网络,自动生成用于测试的用户界面(取代后文将展示的手动编写测试),以及一个测试交易浏览器test.ether.camp。当你的合约准备正式上线之前,使用他们的测试网络会是确保你的智能合约在一个接近真实的环境工作正常的好方法。他们也为正式网络提供了一个交易浏览器frontier.ether.camp,上面可以看到每一笔交易的细节。在本文写作时Ether.Camp的IDE还只能通过邀请注册,预计很快会正式发布。

. Their IDE will support the sandbox testing network by automatically generating a user interface for testing (replacing the manual preparation test to be displayed later), as well as a test transaction browser . When your contract is ready to be officially online, using their testing network will ensure that your smart contract is a good way to work in close proximity to the real environment.

合约和Dapp示例。 在Github上搜索DApp仓库和.sol文件可以看到进行中的有趣东西。这里有一个DApp大列表:dapps.ethercasts.com,不过其中一些项目已经过时。Ether.fund/contracts上有一些Solidity和Serpent写的合约示例,但是不清楚这些例子有没有经过测试或者正确性验证。11月12日的开发者大会DΞVCON1将会有一整天的DApp主题演讲。

contracts and examples of Dapp. Searching Dapp warehouses and.sol files on Github shows interesting things going on. There's a big list of Dapps: , although some of the items are outdated. have some examples of contracts written by Solidity and Serpent, but it is not clear that these examples have been tested or validated. .

流程如下:

The process is as follows:

  1. 启动一个以太坊节点 (例如geth或者testrpc)。
  2. 使用solc*_编译_*智能合约。=> 获得二进制代码。
  3. 将编译好的合约部署到网络。(这一步会消耗以太币,还需要使用你的节点的默认地址或者指定地址来给合约签名。)=> 获得合约的区块链地址和ABI(合约接口的JSON表示,包括变量,事件和可以调用的方法)。(译注:作者在这里把ABI与合约接口弄混了。ABI是合约接口的二进制表示。)
  4. 用web3.js提供的JavaScript API来调用合约。(根据调用的类型有可能会消耗以太币。)

下图详细描绘了这个流程:

This process is described in detail in the following graph:

这里写图片描述

 Write here the picture description

你的DApp可以给用户提供一个界面先部署所需合约再使用之(如图1到4步),也可以假设合约已经部署了(常见方法),直接从使用合约(如图第6步)的界面开始。

Your Dapp can provide users with an interface to deploy the required contract first and then use it (e.g., steps 1 to 4), or it can be assumed that the contract has been deployed (common methods), starting directly with the interface to use the contract (e.g. step 6 of the chart).

Truffle用来做智能合约的测试驱动开发(TDD)非常棒,我强烈推荐你在学习中使用它。它也是学习使用JavaScript Promise的一个好途径,例如deferred和异步调用。Promise机制有点像是说“做这件事,如果结果是这样,做甲,如果结果是那样,做乙… 与此同时不要在那儿干等着结果返回,行不?”。Truffle使用了包装web3.js的一个JS Promise框架Pudding(因此它为为你安装web3.js)。(译注:Promise是流行于JavaScript社区中的一种异步调用模式。它很好的封装了异步调用,使其能够灵活组合,而不会陷入callback hell.)

Truffle is a great test-driven development for smart contracts, and I strongly recommend that you use it in your studies. It is also a good way to learn to use JavaScript Promise, such as deferred and step-by-step. The Promise mechanism is sort of like, "Do this, if that's the result, do it, if that's the result, B... and not wait for the results to come back from there?" (Note: A JS Promise framework for packaging Web3.js .) (It is therefore unlikely that it will be able to adapt to fit for you.)

Transaction times。 Promise对于DApp非常有用,因为交易写入以太坊区块链需要大约12-15秒的时间。即使在测试网络上看起来没有那么慢,在正式网络上却可能会要更长的时间(例如你的交易可能用光了Gas,或者被写入了一个孤儿块)。

Transation times. Promise is very useful for DApp, because it takes about 12-15 seconds to write a transaction into the Etherpan block chain. Even if it does not look that slow on the test network, it may take longer on the official network (e.g. your deal may run out of Gas or be written into an orphan block).

下面让我们给一个简单的智能合约写测试用例吧。

Let's give you an example of a simple smart contract writing test.

首先确保你 1.安装好了solc以及 2.testrpc。(testrpc需要Pythonpip。如果你是Python新手,你可能需要用virtualenv来安装,这可以将Python程序库安装在一个独立的环境中。)

1. Ensure that you are first installed and 2. . (Tettrepc needs Python and

接下来安装 3.Truffle(你可以使用NodeJS’s npm来安装:, 开关可能会需要sudo)。安装好之后,在命令行中输入来验证安装成功。然后创建一个新的项目目录(我把它命名为’conference’),进入这个目录,运行。该命令会建立如下的目录结构:

Truffle (you can use NodeJS's npm for installation). After installation, enter the command line to verify the installation success.

这里写图片描述

write picture description

现在让我们在另一个终端里通过执行来启动一个节点(你也可以用geth):

Now let's start a node with execution in another terminal at (you can also use geth):

这里写图片描述

write picture description

回到之前的终端中,输入。这条命令会部署之前产生的模板合约到网络上。任何你可能遇到的错误信息都会在testrpc的终端或者执行truffle的终端中输出。

Go back to the previous terminal, enter. This command will be contracted to the network before deployment. Any error you may encounter will be exported in the end of testrpc or in the terminal that executes truffle.

在开发过程中你随时可以使用命令来确认你的合约可以正常编译(或者使用),来编译和部署合约,最后是来运行智能合约的测试用例。

You can use orders at any time during the development process to confirm that your contract can be properly compiled (or used) to compile and deploy the contract and, lastly, to run a test case for an intelligent contract.

下面是一个针对会议的智能合约,通过它参会者可以买票,组织者可以设置参会人数上限,以及退款策略。本文涉及的所有代码都可以在这个代码仓库找到。

The following is a smart contract for meetings through which participants can buy tickets, organizers can set a maximum number of participants, and a refund strategy. All codes covered in this paper can be found at .



接下来让我们部署这个合约。(注意:本文写作时我使用的是Mac OS X 10.10.5, solc 0.1.3+ (通过brew安装),Truffle v0.2.3, testrpc v0.1.18 (使用venv))

Let's then deploy this contract. (Note: I used Mac OS X 10.10.5, solc 0.1.3+ (installed through brew), Truffle v0.2.3, tetrpc v0.1.18 (using venv))

这里写图片描述

 Write here a picture description of

(译注:图中步骤翻译如下:)

(translation: step in the graph translated as follows:

使用truffle部署智能合约的步骤:
1. (在新目录中)=> 创建truffle项目目录结构
2. 编写合约代码,保存到文件。
3. 把合约名字加到的’contracts’部分。
4. 启动以太坊节点(例如在另一个终端里面运行)。
5. (在truffle项目目录中)

Steps to deploy smart contracts using truffle:
1. (in a new directory) = > Create truffle project directory structure
2. Prepare contract codes and save them to documents.
3. Add contract names to the `contracts' section.
4. Activate the Tails node (e.g. running in another terminal).
5. (in a truffle project directory)

添加一个智能合约。 在执行后或是一个现有的项目目录中,复制粘帖上面的会议合约到文件中。然后打开文件,把’Conference’加入’deploy’数组中。

Adds a smart contract. Copys the meeting contract on the sticker to the file after execution or in an existing directory. Then opens the file and adds 'Conference' to the 'deploy' array.

启动testrpc。 在另一个终端中启动。

Starttestrpc. Starts in another terminal.

编译或部署。 执行看一下合约是否能成功编译,或者直接一步完成编译和部署。这条命令会把部署好的合约的地址和ABI(应用接口)加入到配置文件中,这样之后的和步骤可以使用这些信息。

compiles or deploys. performs a review of whether the contract is successfully compiled, or directly completes the compilation and deployment. The command adds the address of the deployed contract and the ABI (application interface) to the configuration file, so that the information can be used later and later.

出错了? 编译是否成功了?记住,错误信息即可能出现在testrpc终端也可能出现在truffle终端。

is wrong? has been successful in compiling? Remember, the wrong message is likely to be at the testrpc terminal or at the truffle terminal.

重启节点后记得重新部署! 如果你停止了testrpc节点,下一次使用任何合约之前切记使用重新部署。testrpc在每一次重启之后都会回到完全空白的状态。

Remember to reboot the node! If you stop the node of testrpc, remember to use the redeployment before using any contract next time.

让我们从智能合约头部的变量声明开始:

Let's start with the variable statement on the head of the smart contract:



address。 地址类型。第一个变量是会议组织者的钱包地址。这个地址会在合约的构造函数中被赋值。很多时候也称呼这种地址为’owner’(所有人)。

address. address type. The first variable is the wallet address of the meeting organizer. This address is assigned value in the contractual construction function. It is also called `owner' (all).

uint。 无符号整型。区块链上的存储空间很紧张,保持数据尽可能的小。

uint. Unsigned integer. The storage space on the block chain is tight, keeping the data as small as possible.

public。 这个关键字表明变量可以被合约之外的对象使用。修饰符则表示变量只能被本合约(或者衍生合约)内的对象使用。如果你想要在测试中通过web3.js使用合约中的某个变量,记得把它声明为。

public. is a key word that indicates that variables can be used by objects outside the contract. The embolisms indicate that variables can only be used by objects within the contract (or by derivatives). If you want to use a variable in the contract through web3.js in the test, make a declaration.

Mapping或数组。(译注:Mapping类似Hash, Directory等数据类型,不做翻译。)在Solidity加入数组类型之前,大家都使用类似的Mapping类型。这个声明也可以写作,不过Mapping的存储占用更小(smaller footprint)。这个Mapping变量会用来保存参加者(用他们的钱包地址表示)的付款数量以便在退款时使用。

Mapping or arrays. (translation: Maping has a data type similar to Hash, Directory, etc., is not translated.) A similar Mapping type is used before Solidity joins the array type. This statement can also be written, but Mapping's storage occupancy is smaller. This Mapping variable is used to preserve the number of payments made by participants (expressed with their wallet addresses) to be used in refunds.

关于地址。 你的客户端(比如testrpc或者geth)可以生成一个或多个账户/地址。testrpc启动时会显示10个可用地址:

addresses. Your client (e.g. testrpc or geth) can generate one or more accounts/addresss.

第一个地址, ,是发起调用的默认地址,如果没有特别指定的话。

The first address, the default address to launch the call, if not specified.

组织者地址 vs 合约地址。 部署好的合约会在区块链上拥有自己的地址(与组织者拥有的是不同的地址)。在Solidity合约中可以使用来访问这个合约地址,正如函数所展示的:

Organizer vs contract address. A well-positioned contract has its own address on the block chain (a different address from that held by the organizer). This contract address can be accessed in the Solidity contract, as the function shows:

Suicide, Solidity的好东西。(译注:意为’自杀’, 为Solidity提供的关键字,不做翻译。)转给合约的资金会保存于合约(地址)中。最终这些资金通过函数被释放给了构造函数中设置的组织者地址。这是通过这行代码实现的。没有这个,资金可能被永远锁定在合约之中(reddit上有些人就遇到过),因此如果你的合约会接受资金一定要记得在合约中使用这个方法!

Suicide, Solidity's good stuff. (translation: meaning'suicide', key words for Solidity, without translation.) Funds transferred to the contract will be kept in the contract (address). The funds are eventually released through the function to the organizer's address set in the construction function. This is done through this line of code. Without this, the funds may always be locked in the contract (some people on reddit met), so if you accept the money, you must remember to use this method in the contract!

如果想要模拟另一个用户或者对手方(例如你是卖家想要模拟一个买家),你可以使用可用地址数组中另外的地址。假设你要以另一个用户,, 的身份来买票,可以通过参数设置:

If you want to simulate another user or counterparty (e.g. you're a seller who wants to simulate a buyer), you can use a different address from the available address array. Assuming you want to buy a ticket as another user, you can set it by parameters:



函数调用可以是交易。 改变合约状态(修改变量值,添加记录,等等)的函数调用本身也是转账交易,隐式的包含了发送人和交易价值。因此web3.js的函数调用可以通过指定参数来发送以太币。在Solidity合约中,你可以通过和来获取这些信息:

The function can be called a transaction. The function changes the contract status (modify variable values, add records, etc.) calls itself a transfer transaction, implicitly containing both the sender and the transaction value. So the web3.js function calls can be sent in Chinese with specified parameters. In the Solidity contract, you can access this information through and through:



事件(Event)。 可选的功能。合约中的(充值)和(发送)事件是会被记录在以太坊虚拟机日志中的数据。它们实际上没有任何作用,但是用事件(Event)把交易记录进日志是好的做法。

Events (event). optional functions. The contract (fill) and (send) events are data that will be recorded in the Etheraya virtual machine logs. They do not actually work, but it is good to use the event (event) to record transactions in the logs.

好了,现在让我们给这个智能合约写一个测试,来确保它能工作。

Well, now let's write a test for this smart contract to make sure it works.

把项目目录中的文件重命名为,文件中所有的’Example’替换为’Conference’。

Rename the files in the project directory and replace all 'Example' with 'Conference'.



在项目根目录下运行,你应该看到测试通过。在上面的测试中truffle通过获得合约部署在区块链上的地址。

Runs under the project root directory. You should see the test pass.

让我们写一个测试来初始化一个新的Conference,然后检查变量都正确赋值了。将中的测试代码替换为:

Let's write a test to initialize a new Conference, then check that all variables are correctly assigned. Replace the test code with:



构造函数。 通过调用合约构造函数创造了一个新的Conference实例。由于不指定时会默认使用,它其实可以被省略掉:

Constructive function. creates a new case of Conference by calling the contractual construction function. As defaults are used when not specified, it can actually be omitted:



Promise。 代码中的那些和就是Promise。它们的作用写成一个深深的嵌套调用链的话会是这样:

The ones in the code are Promise. Their role is written as a deep embedded call chain, as follows:



Promise减少嵌套,使代码变得扁平,允许调用异步返回,并且简化了表达“成功时做这个”和“失败时做那个”的语法。Web3.js通过回调函数实现异步调用,因此你不需要等到交易完成就可以继续执行前端代码。Truffle借助了用Promise封装web3.js的一个框架,叫做Pudding,这个框架本身又是基于Bluebird的,它支持Promise的高级特性。

Promise reduces the nesting, flattens the code, allows the call-back, and simplifies the syntax that expresses "do this when it succeeds" and "do that when it fails." Web3.js continue to implement the front-end code by , which itself is based on

call。 我们使用来检查变量的值,例如,还可以通过传参数,例如, 来获取mapping在index 0处的元素。Solidity的文档说这是一种特殊的“消息调用”因为 1.不会为矿工记录和 2.不需要从钱包账户/地址发起(因此它没有被账户持有者私钥做签名)。另一方面,交易/事务(Transaction)会被矿工记录,必须来自于一个账户(也就是有签名),会被记录到区块链上。对合约中数据做的任何修改都是交易。仅仅是检查一个变量的值则不是。因此在读取变量时不要忘记加上!否则会发生奇怪的事情。(此外如果在读取变量是遇到问题别忘记检查它是否是。)也能用于调用不是交易的函数。如果一个函数本来是交易,但你却用来调用,则不会在区块链上产生交易。

cal. We use to check the value of variables, for example, by sending parameters, for example, to obtain the element of mapping at index 0. The document of Solidity says this is a special “message” because 1. does not record and 2. do not need to be initiated from a wallet account/address (and therefore it is not signed by the account holder's private key). On the other hand, the transaction/service will be recorded by the miners and will be recorded on a block chain by an account (i.e., with a signature). Any change in the data in the contract is a transaction.

断言。 标准JS测试中的断言(如果你不小心拼成了复数形式’asserts’,truffle会报错,让你一头雾水),是最常用的,其他类型的断言可以在Chai的文档中找到。

. The assertion in the standard JS test (if you accidentally spell it into a complex form `asserts', truffle will misstate you) is the most common type of assertion that can be found in .

再一次运行确保一切工作正常。

Run again to ensure that everything works properly.

现在我们测试一下改变变量的函数能工作。在文件的的函数体中添加如下测试用例:

Now we test the function that changes the variable to work. Add the following test example to the function of the file:



这里的新东西是调用函数的那一行。对于调试很有用,用它能在运行truffle的终端中输出信息。在关键点插入可以查看执行到了哪一步。记得把Solidity合约中函数被声明为,否则你不能调用它:

The new thing here is the line in which the function is called. It's useful for debugging, so it can be used to output information in the terminal running truffle. Insert the key point to see what step is taken. Remember to declare the function in the Solidity contract, otherwise you can't call it:







现在让我们调用一个需要发起人发送资金的函数。

Now let's call a function that requires the sponsor to send the funds.

Wei。 以太币有很多种单位(这里有个很有用的转换器),在合约中通常用的是Wei,最小的单位。Web3.js提供了在各单位与Wei之间互相转换的便利方法,形如。JavaScript在处理很大的数字时有问题,因此web3.js使用了程序库BigNumber,并建议在代码各处都以Wei做单位,直到要给用户看的时候(文档

Wei. There are a number of units in Teen currency (there is a useful ), which is usually used in the contract. Web3.js provides a convenient way of switching between units and Wei. JavaScript has problems in processing large numbers, so Web3.js uses and recommends that Wei units be used in all parts of the code until the time of the user's view (.

账户余额。 Web3.js提供了许多提供方便的方法,其中另一个会在下面测试用到的是。记住发送给合约的资金会由合约自己持有直到调用。

account balance. Web3.js provides a number of convenient , one of which will be tested below. Remember that the funds sent to the contract will be held by the contract itself until called.

在的函数体中插入下面的测试用例。在高亮显示的方法中,测试用例让另一个用户()以的价格买了一张门票。然后它检查合约的账户余额增加了,以及购票用户被加入了参会者列表。

Inserts the following test example into the function. In the highlighted method, the test allows another user () to buy a ticket at a price. It then checks that the account balance of the contract has increased and that the buyer has been added to the list of participants.

这个测试中的是一个交易函数:

This test is for a transaction function:



交易需要签名。 和之前的函数调用不同,这个调用是一个会发送资金的交易,在这种情况下购票用户()会用他的私钥对调用做签名。(在geth中用户需要在发送资金之前通过输入密码来批准这个交易或是解锁钱包的账户。)

transactions require a signature. , unlike the previous function call, is a transaction that sends money, in which case the person buying the ticket(s) will use his private key pair as a signature. (The user in geth needs to approve the transaction or unlock the wallet account by entering a password before sending the money.)

toNumber()。 有时我们需要把Solidity返回的十六进制结果转码。如果结果可能是个很大的数字可以用来处理因为JavaScript直接对付大数要糟。

toNumber(). Sometimes we need to recode the hexadecimal results that Solidity returns. If the result is likely to be a big number, it can be handled because JavaScript directly deals with large numbers.

最后,为了完整性,我们确认一下方法能正常工作,而且只有会议组织者能调用。下面是测试用例:

Finally, for the sake of integrity, we confirm that the method works properly and that only the organizers of the meeting can call.



这个测试用例覆盖的Solidity函数如下:

The Solity function, which is covered by this test, is as follows:



合约中发送以太币。 展示了如何获取该会议合约实例的地址,以变接下来检查这个地址的余额(或者直接使用)。合约通过方法把资金发回了购票人。

contracts send in TT. shows how to get the address of the conference contract to check the balance (or direct use) of the address. The contract returns the money to the purchaser.

交易无法返回结果给web3.js。 注意这一点!函数会返回一个布尔值,但是这在测试中无法检查。因为这个方法是一个交易函数(会改变合约内数据或是发送以太币的调用),而web3.js得到的交易运行结果是一个交易哈希(如果打印出来是一个长长的十六进制/怪怪的字符串)。既然如此为什么还要让返回一个值?因为在Solidity合约内可以读到这个返回值,例如当另一个合约调用的时候。也就是说Solidity合约可以读取交易运行的返回值,而web3.js不行。另一方面,在web3.js中你可以用事件机制(Event, 下文会解释)来监控交易运行,而合约不行。合约也无法通过来检查交易是否修改了合约内变量的值。

transactions cannot return results to Web3.js. Note this! The function returns a boolean value, but this cannot be checked in the test. Because this method is a transaction function (which changes the data in the contract or sends a call in NT), and the transaction run results for Web3.js are a transaction Hashi (if printed out is a long hexadecimal/eccentric string). Why then let the return value be allowed? Because the return value can be read in the Solidity contract, for example when another contract is called. That is, the Solidity contract can read the return value of the transaction, which is not possible for Web3.js. On the other hand, in Web3.js, you can monitor the operation of the transaction (event, as explained below), but not for the contract.

关于sendTransaction()。 当你通过web3.js调用类似或者的交易函数时(使用),交易并不会立即执行。事实上交易会被提交到矿工网络中,交易代码直到其中一位矿工产生一个新区块把交易记录进区块链之后才执行。因此你必须等交易进入区块链并且同步回本地节点之后才能验证交易执行的结果。用testrpc的时候可能看上去是实时的,因为测试环境很快,但是正式网络会比较慢。

about sendTransaction(). transactions do not take place immediately when you call similar or transactional functions (using) through web3.js. In fact, the transaction is submitted to the miners' network, until one of the miners produces a new block to record the transaction into the block chain. So you have to wait for the transaction to enter the block chain and synchronize back to local nodes before verifying the outcome of the transaction. The testpc may appear to be real-time because the test environment is fast, but the formal network will be slow.

事件/Event。 在web3.js中你应该监听事件而不是返回值。我们的智能合约示例定义了这些事件:

Event/Event. In Web3.js you should listen to . Our smart contract example defines these events:



它们在和中被触发。触发时你可以在testrpc的输出中看到日志。要监听事件,你可以使用web.js监听器(listener)。在写本文时我还不能在truffle测试中记录事件,但是在应用中没问题:

They are triggered in the process. You can see logs in the output of testrpc at the time of triggering. To listen to an event, you can use the web.js listening device (listener). I can't record an event in a truffle test at the time of writing, but it's okay in the application:



过滤器/Filter。 监听所有事件可能会产生大量的轮询,作为替代可以使用过滤器。它们可以更灵活的开始或是停止对事件的监听。更多过滤器的信息可查看Solidity文档

Filter/Filter. Listening to all events may result in a large number of rounds of questioning as an alternative to using filters. They can start with more flexibility or stop listening to events. More filter information can be found in .

总的来说,使用事件和过滤器的组合比检查变量消耗的Gas更少,因而在验证正式网络的交易运行结果时非常有用。

In general, the combination of events and filters is less expensive than the Gas used to check variables and is therefore very useful in validating the transaction results of the official network.

Gas。 (译注:以太坊上的燃料,因为代码的执行必须消耗Gas。直译为汽油比较突兀,故保留原文做专有名词。)直到现在我们都没有涉及Gas的概念,因为在使用testrpc时通常不需要显式的设置。当你转向geth和正式网络时会需要。在交易函数调用中可以在对象内设置Gas参数。Web3.js提供了调用来获取当前Gas的价格,Solidity编译器也提供了一个参数让你可以从命令行获取合约的Gas开销概要:。下面是的结果:

Gas. (Reference: fuel in Taiwan, because code enforcement has to consume Gas. Directly translated into gasoline, so the original text is kept as a noun.) Until now, the concept of Gas has not been addressed, because it is usually not required to be visible when using testrpc. When you turn to geth and the official network, it is necessary to set the Gas parameters in the object. Web3.js provides to obtain the current price of Gas.

下面的段落会假设你没有网页开发经验。

The paragraph under assumes that you do not have web page development experience.

上面编写的测试用例用到的都是在前端界面中也可以用的方法。你可以把前端代码放到目录中,运行之后它们会和合约配置信息一起编译输出到目录。在开发时可以使用命令在有任何变动时自动编译输出到目录。然后在浏览器中刷新页面即可看到目录中的最新内容。(可以启动一个基于目录的网页服务器。)

The tests above are used for methods that can also be used in front-end interfaces. You can place front-end codes in the directory, and then they are translated into the directory together with the contractual configuration information. You can use the command to automatically edit the output to the directory at the time of development when any changes are made. The latest contents of the directory can then be seen in a new page on the browser. (A directory-based web server can be activated.)

目录中有一些样板文件帮助你开始:

There are some templates in the directory that help you start:

会加载:

Will be loaded:

因此我们只需要添加代码到就可以了。

So we just have to add code to it.

默认的会在浏览器的console(控制台)中输出一条”Hello from Truffle!”的日志。在项目根目录中运行,然后在浏览器中打开文件,再打开浏览器的console就可以看到。(大部分浏览器例如Chrome中,单击右键 -> 选择Inspect Element然后切换到Console即可。)

The default output of a log "Hello from Trade!" in the browser's console! Runs in the project root directory, then opens the file in the browser and then opens the browser's console. (Most browsers, for example, in Chhome, click right -> select Inspect Regulation and then switch to Console.)

在中,添加一个在页面加载时会运行的调用。下面的代码会确认web3.js已经正常载入并显示所有可用的账户。(注意:你的testrpc节点应该保持运行。)

In which, add a call that will run when the page is loaded. The code below confirms that web3.js is properly loaded and displays all available accounts. (Note: your testrpc node should remain running.)



看看你的浏览器console中看看是否打印出了一组账户地址。

Check your browser console to see if you printed out a set of account addresses.

现在你可以从中复制一些代码过来(去掉只和测试有关的断言),将调用返回的结果输出到console中以确认代码能工作。下面是个例子:

Now you can copy some of the codes from them (remove only the test-related assertions) and export the returned results to the console to confirm that the code works. Here's an example:



上面的代码应该输出如下:

The code above should be exported as follows:

(console输出的warning信息可忽略。)

(Console output of warning information is negligible.

现在起你就可以使用你喜欢的任何前端工具,jQuery, ReactJS, Meteor, Ember, AngularJS,等等等等,在目录中构建可以与以太坊智能合约互动的DApp界面了!接下来我们给出一个极其简单基于jQuery的界面作为示例。

From now on, you can use any front-end tool you like, jQuery, ReactJS, Meteor, Ember, AngularJS, etc., and so on, to build a Dapp interface in the directory that can interact with an Ethernomy smart contract. Let us then give an example of an extremely simple jQuery-based interface.

这里是index.html的代码,这里是app.js的代码

This is the code for rel="noopener"index.html, and the code for .

通过界面测试了智能合约之后我意识到最好加入检查以保证相同的用户不能注册两次。另外由于现在是运行在testrpc节点上,速度很快,最好是切换到geth节点并确认交易过程依然能及时响应。否则的话界面上就应该显示提示信息并且在处理交易时禁用相关的按钮。

After testing the smart contract through the interface, I realized that it would be better to include a check to ensure that the same user could not register twice. And since it is now running on the testrpc node, fast, it is better to switch to the geth node and confirm that the transaction is still responsive in time. Otherwise, the interface should show the alert information and disable the relevant buttons when processing the transaction.

尝试geth。 如果你使用geth, 可以尝试以下面的命令启动 - 在我这儿(geth v1.2.3)工作的很好:

If you use geeth, you can try to start with the following command - good work at my place:



这条命令解锁了两个账户, 和。1. 在geth控制台启动后你可能需要输入这两个账户的密码。2. 你需要在文件里面的’alloc’配置中加入你的这两个账户,并且给它们充足的资金。3. 最后,在创建合约实例时加上gas参数:

This command unlocks two accounts, and 1. You may need to enter the passwords for both accounts after the Geth console is activated. 2. You need to add your two accounts to the `alloc' configuration in . Finally, add gas parameters to the creation of the contract:



然后把整个, 流程重来一遍。

And then put the whole, the process over and over again.

教程中的代码。 在这篇基础教程中用到的所有代码都可以在这个代码仓库中找到。

All codes used in this basic curriculum can be found in this code warehouse at .

自动为合约生成界面。 SilentCicero制作了一个叫做DApp Builder的工具,可以用Solidity合约自动生成HTML, jQuery和web.js的代码。这种模式也正在被越来越多的正在开发中的开发者工具采用。

automatically generates interfaces for contracts. has developed a tool called , which can be used to automatically generate HTML, jQuery and Web.js codes from the Solidity Contract. This model is also being used by a growing number of developers.

教程到此结束! 最后一章我们仅仅学习了一套工具集,主要是Truffle和testrpc. 要知道即使在ConsenSys内部,不同的开发者使用的工具和框架也不尽相同。你可能会发现更适合你的工具,这里所说的工具可能很快也会有改进。但是本文介绍的工作流程帮助我走上了DApp开发之路。

This is the end of the program! The last chapter we have learned only a set of tools, mainly Truffle and testrpc. Know that even within ConsenSys, the tools and frameworks used by different developers are different. You may find tools that are more suitable for you, and the tools here may be improved soon. But the workflow described here has helped me on the way to the Dapp development.

(⊙ω⊙) wonk wonk

感谢Joseph Chow的校阅和建议,Christian Lundkvist, Daniel Novy, Jim Berry, Peter Borah和Tim Coulter帮我修改文字和debug,以及Tim Coulter, Nchinda Nchinda和Mike Goldin对DApp前端步骤图提供的帮助。

thanks Joseph Chow for his study and advice, Christian Lundkvist, Daniel Novy, Jim Berry, Peter Borah and Tim Coulter for helping me with text and debug, and Tim Coulter, Nchinda Nchinda and Mike Goldin for helping with the Dapp front-end map.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 孟洪涛谈威科夫交易法

    孟洪涛谈威科夫交易法
     大咖看市 | 判断趋势的工具(一)  原创2016-04-30孟洪涛期货日报 在讨论判断工具之前,我们先说下判断趋势。趋势包括以下几个阶段:趋势的开始,趋势在运行中,以及趋势的结束。我们判断趋势就是能够找出当前市场处于趋势的哪个阶段,以便调整交易。趋势的不同阶段伴随着交易者不同的行为,起始阶段是进场时机,结束阶段是出场时机,同时也是准备反转的进场时机。但是在交易中遇到的最头疼的问题是以上几个趋势阶段并不会白纸黑字表现出来。 ...
  • ??今日BTC和ETH行情分析以及对BICO的看法

    ??今日BTC和ETH行情分析以及对BICO的看法
    ? 如果你刚认识我那么此刻开始你的幸福? 幸运之路正式开启!? ? 历史记录皆可追溯,往期的记录依然可查,山水相逢,皆是缘!?以后也会经常分享一些看好现货给大家! ? 本周热点 ? ? ? ? ? TON 启动公...
标签列表