区块链DApp开发环境 embark 初探

资讯 2024-06-21 阅读:28 评论:0
美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址

embark是一款特定于Ethereum区块链平台的DApp开发环境,辅助开发者创建、构建编译、测试和部署DApp,可无缝集成计算(EVM)、存储(IPFS/Swarm)和网络(Whisper)资源。

embark is a Dapp development environment specific to the District Block Platform in Etheeum, which supports developers in creating, constructing, translating, testing and deploying Dapps that can be computed (EVM), stored (IPFS/Swarm) and network (Whisper) resources.

在尝试embark并和truffle框架进行对比之后,我总结以下几个方面的优势:功能全面,上手迅速,反馈快速,可视化程度高,合约可调试。

After trying to compare embark and the truffle framework, I have summarized the advantages of being fully functional, fast-tracked, fast feedback, high visualization and verifiability of contracts.

正如embark概览所言,embark并不仅仅是一款只提供构建编译、测试部署功能的开发工具,还是一整套的开发环境。它包含了智能合约自动部署,客户端(UI)开发,测试,DApp分布式托管(IPFS/Swarm),点对点通信(Whipser)和组件监控、在线IDE及代码调试(Cockpit)等功能。

As the "https://links.jianshu.com/go?to=https%3A%2F%2Fembark.status.im%2Fdocs%2Foverview.html" Target="_blank" rel="nofollow" overview , Embark is not just a development tool to construct, test and deploy functions, but a set of development environments. It includes smart contract automatic deployment, client (UI) development, testing, DApp distribution hosting (IPFS/Swarm), point-to-point communication (Whipser) and component monitoring, online IDE and code debugging (Cockpit).

如果和truffle框架比较,embark几乎包含了它提供的所有功能。不过,embark缺失了truffle在migration方面的功能,基于对不可变基础设施的考量,embark有必要拥抱这项标准实践。

Compared to the truffle framework, Embark contains almost all the functions it provides. However, Embark lacks the truffle function in the field of migration, and it is necessary for embark to embrace this standard practice on the basis of considerations of immutable infrastructure.

embark考虑了单独开发智能合约的可能性,所以允许开发者在创建项目时只创建智能合约项目结构,通过启用选项。而且在构建编译时,也可以指定命令单独构建智能合约。

Embark considers the possibility of developing a separate smart contract, so the developers are allowed to create only an intelligent contract project structure at the time the project is created, by enabling options. Also, when building a compilation, you can specify a separate command to build a smart contract.

这个维度虽然有点主观,但是很值得拿出来说。一般学习新的工具,需要花很多时间看文档学习基本概念和操作流程,最恼火的就是熟悉各种配置项,当你左支右绌,手忙脚乱让工具程序跑起来,除了浪费时间,也侧面证明该工具不够成熟、对开发者不友好。

This dimension, although somewhat subjective, is worth saying. It takes a lot of time to learn about the basic concepts and operating processes of the document, and the most irritated is to be familiar with the configurations, when you have a left-right deficit and are busy running the tool program, and in addition to wasting time, it proves that the tool is immature and unfriendly to the developers.

很意外的是,本来以为这么一个大而全的开发环境设置起来一定得耗费不少时间,结果却是除了用报出一个compiler和yarn不兼容后,改成了安装,就再没有特别恼人的问题出现了。

Surprisingly, it would have taken a lot of time to set up such a large and comprehensive development environment, and as a result, there had been no particularly irritating problems, except for the incompatibility of a compiler and yarn.


注意:
上面的安装错误其实是因为embark对于yarn的版本有一定的要求,从embark源码中可以得到如下前置条件。

Note: The installation error on
is due to the fact that Embark has certain requirements for the version of Yarn and the following preconditions can be obtained from the embark source code.


我当前的yarn版本是1.6.0,使用升级到1.15.2就可以全局安装了。

My current version of Yarn is 1.6.0, which can be installed on a global scale using upgrades to 1.15.2.



会启动一个命令行中可视化界面,里面会告诉你当前Dapp的状态,包括智能合约是否部署,哪些组件服务可用,最最重要的是它会告诉你接下来你该做什么!在Logs视窗中,embark试图告诉你开发环境确实哪些依赖服务,比如geth节点没有启动(事实上,可以用gananche-cli代替),ipfs节点未侦测到,Cockpit Web UI所在端口还有Dapp服务的入口等等。而console视窗则是命令交互入口,一条命令就能展示很多有用信息。

In the Logs window, Embark tries to tell you exactly what the development environment depends on, such as if the geth node has not started (in fact, it can be replaced by gananche-cli), that the ipfs node has not been detected, and that the Cockpit Web UI portal and the Dapp service portal are available, among other things. And the console window is the interactive entry to the command, and a command can display many useful information.

Dashboard

以上这些信息都无需查看文档便可以获得,个人觉得从尝试中学习是特别有趣的事情。

None of the above information is available without looking at the document, and individuals find it particularly interesting to learn from the experiment.

我一般拿从零到写出第一行程序的时间作为上手快慢的标准。这行程序是用来试验,未必得手写,所以我选用了truffle自带的样例和。

I usually use the amount of time from zero to write down the first line of the program as a criterion for slowness. The program is used to test, not necessarily handwritten, so I've chosen the example of truffle.



当把这两个智能合约文件放到项目根目录下contracts/目录中后,合约代码被自动编译,并在Contracts视窗中展示出来,状态为Deployed,这表明智能合约已经被部署到区块链网络里。之后,我进入Cockpit Web UI,惊喜地发现这个服务俨然就是一个高配版的etherscan.io,通过它不仅可以查看部署之后的合约,甚至还可以调用合约方法。

When these two smart contract documents were placed under the project root directory contracts/, the contract code was automatically compiled and displayed in the Contracts window in the state of Deployed, which indicates that the smart contract has been deployed into the network of blocks. After that, I entered Cockpit Web UI, and it was surprised to discover that the service was a high-profile version of , not only to view post-deployment contracts, but even to apply contractual methods.

估算下来,我用embark写完第一行代码的时间基本可以忽略不计。

It's estimated that the time I wrote the first line of code with embark is almost negligible.

写程序都希望其可行性能被快速验证,因为只有这样才能方便快速地迭代出正确功能的程序。我所知道的前端开发者是把这个过程做到极致的群体,比如Liveloading;embark对于智能合约也提供了一致的功能。当修改合约文件并保存时,embark会自动检测变更同时重新编译再部署,这个过程非常快速(当然,embark对于哪些修改的合约需要重新部署是有一定限制的,而且据我观察,这里面有些潜在的bug,比如修改合约constructor中的内容就不会触发重新构建,即便用也不行,这个和文档的描述有些出入,值得花时间研究下)。

It is hoped that its feasibility will be validated quickly, because it is the only way to facilitate quick succession to the correct function. The front-end developers, as I know, are groups that make the process extremely effective, such as Liveloading; embark, which also provides a consistent function for intelligent contracts. When contractual documents are modified and saved, Embark automatically detects changes while reprogramming and resells the process very quickly (of course, Embark has some limits on which contracts are subject to redeployment, and, as I see it, some potential bugs, such as the content of the contract changes, are not capable of triggering a re-construction, even if not working, and there are some discrepancies in the description of this and the document that are worth studying in time).

自动重新构建和部署合约对程序员的效率提升很有帮助,但是无法快速验证同样达不到目的。所幸的是,embark不仅提供了Cockpit这样的可视化工具辅助验证合约的正确性,而且还提供embark console,在console中可以调用部署合约的实例,比如:输入就能获取部署好的实例,有了合约实例就可以调用其上的方法进行数据校验。

Auto-reconstructing and deploying contracts help to improve the efficiency of programmers, but they also fail to be validated quickly. Fortunately, Embark not only provides the validity of the contracts as visual aids such as Cockpit, but also provides examples of deployment contracts that can be called in console, for example, where input can capture good deployments, and where contracts can be called for data validation using their methods.

同样重要的是,embark支持js和sol版本测试,我可以像使用truffle一样使用TDD的方式开发DApp了。

Equally important, Embark supports js and sol versions of the test, and I can use TDD to develop Dapps as much as I can use it.

当在终端中运行时,embark会自动进入可视化界面(dashboard)。这里面监控的信息会实时告诉你DApp开发的状态。除此之外,embark还提供了DApp的Web server,Cockpit Web UI页面,这些绝对是开发DApp极大的助力。

When running in the terminal, Embark automatically enters the visual interface (dashboard) >. In addition, Embark also provides the Web Server, Cockpit Web UI page of DApp, which is absolutely an extremely useful tool for the development of DApp.

如果不想使用dashboard,可以通过禁用。不过,根据我的经验,禁用dashboard的结果是没法直接拿到进入Cockpit的访问token,还需要运行进入命令行单独获取。

If you do not want to use dashboard, it can be disabled. However, in my experience, the result of banning dashboard is that access to to token into Cockpit cannot be obtained directly, but it also needs to be obtained separately from the running access command line.

从上面这点来看,embark在组件化方面做得相当出色,虽然功能大而全,但是并没有限制你删减不必要的组件、独立启用感兴趣的组件

From this point of view, Embark has done quite well in the assembly process, although it is large and complete, but it does not limit you to cutting off unnecessary components and independently using those that are of interest.

调试合约在以前的开发过程中还是比较难的,不过借助于Cockpit,embark也提供了在线调试的能力。Cockpit内置一个编辑器,它和本地的开发目录保持一致,该编辑器就提供了debug功能。另外,进入Explorer页,我们甚至可以对某次的tx进行debug验证这次合约调用的真实数据流转情况。

Debug contracts were difficult in the previous development process, but with the help of Cockpit, Embark also provides online debug capabilities. Cockpit has an editor that is consistent with the local development directory, which provides debug functions. Also, on the Extraorer page, we can even debug the actual data flow that the contract calls for.

Explorer & Debug

总的来说,embark是一款优秀的区块链开发环境。相比较truffle的专注于合约工程化的努力,embark的功能更加丰富,而且各组件组合性很强。对于开发者而言,快速开发出DApp才是真的诉求,而embark显然在这一方面具备很大的优势。

Compared to truffle’s efforts to focus on contractual engineering, embark is more functional and has a strong mix of components. For developers, the rapid development of Dapp is a real claim, and Embark clearly has a great advantage in this respect.

工具版本号

Tool Version Number



embark默认开发时都是 development 环境,为了对接正确的ganache-cli(模拟以太坊客户端)端口,我们需要修改文件中到ganache-cli默认的8545端口。

Embark defaults to develop environments, and in order to match the correct ganache-cli port, we need to modify the file to ganache-cli default port 8545.

先执行,然后启动,此时就可以在查看DApp的界面了。

Execute and then start, and then view the Dapp interface.

首先得安装IPFS的客户端,然后运行如下命令:

First you have to install an IPFS client and then run the following command:


当ipfs启动完成后,embark的dashboard会显示ipfs节点已连接。此时执行,构建出来的dist目录就会被分发到ipfs网络,然后就可以通过内容寻址(content-addressed)的方式访问这个静态网站了。

When Ipfs start, the dashboard of Embark will show that the ipfs node is connected. Implementation will take place, and the disist directory will be distributed to the ipfs network, and the static site will be accessed by means of content-addressed.

IPFS distribution of static pages

于 2019-05-07

at 2019-05-07

美化布局示例

欧易(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...
  • 134 USD toBTC Calculator -

    134                            USD                        toBTC                        Calculator -
    For the week (7 days) Date Day 134 USD to BTC Changes Changes % June...
  • 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)汇率更新时...
  • 12年怎么购买比特币?比特币投资,轻松掌控

    12年怎么购买比特币?比特币投资,轻松掌控
    12年怎么购买比特币?买卖比特币可以通过以下交易所进行购买,分别是:欧易官网平台、ZG交易所、艾戴克斯交易所、C2CX交易软件、BaseFEX交易APP、波网交易平台、安银交易所、BitMart交易软件、紫牛币交所交易APP和澳网(AOMEX)交易平台等等十大平台下载,高效安全的数字货币交易平台。How do you buy bitcoins in 12 years? Bitcoins can be purchased through ten major platforms...
  • 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...
标签列表