原文链接:https://medium.com/better-programming/the-top-blockchain-developer-frameworks-for-2021-89afa5e7bd04 原文标题:The Top Blockchain Developer Frameworks for 2021 原文作者:Patrick Collins _
The best smart contract and blockchain developer frameworks, focusing on Ethereum smart contracts across all languages 最好的智能合约和区块链开发者框架总结,并专注于所有适用语言的以太坊智能合约开发。
Smart contract development frameworks make engineers’ lives easier by allowing them to deploy and test their smart contracts. I took hours and days to go through every recommended framework from ConsenSys and the Ethereum website to see which ones are the best for 2021. You can see my experimentation with the platforms on GitHub. 智能合约开发框架使得工程师们能够更加轻松地部署和测试他们的智能合约。我花了几天加数小时时间浏览了ConsenSys和以太坊官网上推荐的每个框架,了解了一下最适合2021年的是哪些框架。可以看到我的存放在Github上的对这些平台的实验记录。
Not only that, but I’ve conducted hundreds of interviews with blockchain hackathon participants and gone through hundreds of hackathon submissions, looking for which tools perform the best and have the best developer experience. I also do a lot of work using each framework myself, and I want to set myself up for 2021 right. I’ve done the hard work for 2021 so you don’t have to. 不仅如此,我还对区块链黑客松的参与者们进行了数百次的采访,也完成了数百次黑客松的提交,试着找到哪些工具表现最好,以及开发者的体验最佳。我自己也使用每个框架做了许多工作,我想为2021年做好准备。我已经为2021年的准备做了这些艰难的工作,因此读到这篇文章的你就无需再重复这些工作了。
The criteria used was simple. The framework needs to: 本文采用的标准很简单。开发框架需要能够:
The third criterion is important because it allowed me to test how the framework interacts with other packages and integration testing. Working with oracles and third-party tools like OpenZeppelin is basically a must for 2021, which is why this last piece is so important. 其中第三个标准很重要,因为它使我能够测试该框架如何与其他软件包交互以及进行集成测试。基本上,在2021年使用预言机和OpenZeppelin等第三方工具进行开发成为了必备条件,这也是为什么最后一条标准如此重要的原因所在。
We are going to briefly mention some other important tools that you need to know about for 2021, but this article will not go over beginner tools, like an ETH wallet, an Ethereum client, or a text editor. 我们将简要介绍一些2021年你需要了解的重要工具,但本文不会涉及初学者工具,比如ETH钱包,以太坊客户端或文本编辑器等内容。
Video Walkthrough 视频演示
When it came down to it, there are three smart contract development frameworks that I would recommend to anyone. Each has a slightly different flavor and reason why you’d choose it. They are: 归根结底,我会向每个人推荐三个智能合约开发框架。每种框架的品味和为什么会选择它们的原因都略有不同。它们分别是:
Let’s go through each and understand why you’d want to use it, why it made the top of the list, and anything else noteworthy. 让我们先仔细阅读本文,了解为什么要使用这些框架,为什么它们排在列表的顶部以及其他值得注意的地方。
Image source: Hardhat 图片来源:Hardhat
Hardhat is one of the best frameworks out there, having some of the fastest tests, best tutorials, and easiest integrations. Honestly, everyone who enjoys JS frameworks should try out Hardhat at some point. It’s really easy to get going, it has blazing-fast tests, and getting started is really simple. Their Discord has always been really quick to respond to questions as well, so if you run into issues, you can always ask for help. They use Waffle and Ethers.js for testing, which is arguably the better JavaScript smart contract framework, due to some really nice quality-of-life improvements over web3.js. They also have access to direct integration with OpenZeppelin’s upgradeable smart contract plugin, which is a huge win. Hardhat是目前最好的框架之一,它拥有一些最快的测试,最好的教程和最简单的集成。老实说,每个喜欢JS框架的人都应该在某个时候试一下Hardhat。它真的很容易上手,有非常快速的测试,而且入门非常简单。他们的Discord社群也总是能非常迅速地回答问题,所以如果遇到问题,你总能很快得到帮助。他们使用Waffle和Ethers.js进行测试,由于对web3.js进行了非常不错的质量改进,因此可以说这一个是更好的JavaScript智能合约框架。他们还可以与OpenZeppelin的可升级智能合约插件直接集成,这是一个巨大的优势。
This project has an awesome feel to it: It’s clean. It does what you want it to do. It’s really fast. The project is continuously improving, and they are clearly dedicated to making the smart contract developer's life easier. 这个项目给人一种很棒的感觉:它很干净。它会执行你想要的操作,而且它真的很快。这个项目正在持续改进,显然他们正努力提升智能合约开发者的体验。
Summary
总结:
Image source: TruffleSuite 图片来源:TruffleSuite
Truffle has been the default framework for a few years now, and for good reason. It is a powerful framework that sets the standard for many others to follow. You’ll find easily the most projects using this platform, so finding examples is easy. Truffle also can be easily integrated with its sister tools Drizzle and Ganache. Ganache in particular is one of the most popular ways for engineers to run a local blockchain. For those looking for even more tools, you can pay for an upgraded Truffle team account and get access to smart contract continuous integration, visual deployments, and monitoring. They also have access to direct integration with OpenZeppelin’s upgradeable smart contract plugin, which is a huge win. They clearly are a group of talented engineers who want to make the world a better smart contracted place. Truffle几年来一直都是默认的开发框架,这是有充分理由的。它是一个强大的框架,并为其他框架树立了可遵循的标准。你可以很容易看出绝大部分项目都是使用这个平台,因此查找示例很容易。Truffle还可以轻松地与其姐妹工具Drizzle和Ganache集成在一起。特别是Ganache,它是工程师们在本地运行区块链的最流行方法之一。如果想要更多工具,你可以选择付费获得升级的Truffle团队帐户,可以获得智能合约的持续集成,可视化部署和监视等功能。他们还可以与OpenZeppelin的可升级智能合约插件直接集成,这是一个巨大的优势。他们显然是一群天才工程师,他们想要给世界提供一个更好的智能合约开发工具。
Truffle tests don’t run as fast as Hardhat’s do, and due to the high volume of users, getting support can be difficult. I’m looking forward to seeing how they will improve this project since being acquired by ConsenSys. Their documentation appears to be starting to fall off and can be hard to follow, but if you google an error you run into, you’ll most likely run into someone who has run into the error and solved it before. I’ve found some of the best ways to improve the project is to leave an issue on their GitHub. It’s our open source duty anyway to keep the ecosystem growing stronger and better! Truffle测试的运行速度不如Hardhat那样快,并且由于用户数量众多,获得支持可能很困难。自从被ConsenSys收购后,我很期待看到他们将如何改进这个项目。可他们的文档质量似乎开始下滑,并且很难遵循,但是如果你通过Google搜索遇到的错误,很可能会遇到曾经遇到过同样错误并已解决的人。我发现了一些改进项目的最佳方法是将问题留在他们的GitHub上。无论如何,保持生态系统不断壮大并逐渐变好是我们的开源社区的职责所在!
Due to almost everyone is familiar with it, getting support from your peers is usually easy. I really hope to see the team get some more support on this project, as they have so_ _many users. I hope they see this article and work to improve their documentation so that they can stay as one of the go-to platforms for testing and deploying smart contracts. 由于几乎人人都熟悉它,因此获得同行们的支持常常很容易。我真心希望看到这个团队在这个项目上获得更多支持,因为他们有这么多用户。同时我也希望他们能看到本文并致力于改进文档,从而使其能够继续作为测试和部署智能合约的首选平台之一。
Summary
总结:
Image source: Brownie 图片来源:Brownie Heavily inspired by Truffle, this is basically the Python equivalent, with some added quality-of-life changes. This project literally came about from the same frustration most Python engineers share: They don’t like JavaScript. Due to it being written in Python, a lot of the headaches that come with working with JavaScript are removed, and you get this wonderfully simple framework for working with and deploying smart contracts. 这个框架深受Truffle框架的启发,基本上可以看作是Truffle的Python版本,并增加了一些代码质量的改进。这个项目起因于大多数Python工程师们都会感到的沮丧:他们不喜欢JavaScript。由于它是用Python编写的,消除了使用JavaScript带来的许多麻烦,因此它是一个能处理和部署智能合约的美好的简单的框架。
Being someone who loves Python myself, I’m really excited for the future of this project, and as adoption picks up, it looks like more and more projects are looking at Python and this framework to deploy their smart contracts. I’ve started using Brownie as my go-to framework and have been loving it. I’ve chatted with a few of the people who work on it more, and they are a really intelligent group. Yearn.finance seems to have bought in as well. 作为一个本身就喜欢Python的人,我对这个项目的未来感到非常兴奋,随着采用率的提高,越来越多的项目正在使用Python和本框架部署他们的智能合约。我已经开始使用Brownie作为我的入门框架,并且一直都很喜欢它。 我已经和开发此框架的一些人聊过,他们是一个非常聪明的团队。Yearn.finance好像也已经采用了这个框架。
If you come from the Python world or want a really simple, clean framework, this is for you. No questions asked. 如果你来自Python世界,或者想要一个非常简单干净的框架,那么这是为你准备的,毫无疑问。
One more! I know I said only three, but I think this next one deserves a spot up here as well. 还有一个项目也值得一提!我知道我前面说只有三个,但我认为第四个也应该在这里占一席之地。
Summary
总结
Image source: Embark 图片来源: Embark I was surprised to see a framework outside of the top three with so many stars on GitHub (3.1k). This tool has a ton of bells and whistles. It took me a little bit of work to understand quite what was going on, but that’s because Embark is meant to be an entire dApp framework. It’s a full-stack blockchain platform. I was able to deploy my Chainlink contracts to the Kovan network after some help from their Gitter (and an issue created on their GitHub; remember, open source duty!). It comes with a UI that allows you to interact with the blockchain and your contracts in a GUI. It looked like there was a bit of a learning curve that I didn’t spend enough time to get over, but it showed a lot of promise. This is why I wanted to include it here, as I feel there was a lot that I didn’t fully digest. 我很惊讶地看到在排名前三的框架之外有另一个项目在GitHub(3.1k)上这么多的标星。这个工具非常花哨。我花了好一些工夫才理解到它想做什么,但这也是因为Embark是一个完整的dApp框架。这是一个全栈的区块链平台。在它们的Gitter(以及在GitHub上创建的问题;请记住,开源的职责!)的帮助下,我能够将Chainlink合约部署到Kovan网络。它有一个UI,允许你在GUI中与区块链和智能合约进行交互。看起来它的学习曲线有一点陡峭,我没有花足够的时间来掌握,但它展示了很多可能性。这就是为什么我想将它放在这里的原因,因为我觉得还有很多东西我没有完全消化。
I’d love to see people try this framework out some more and see the power. I feel like I might not be able to do it justice here due to my limited time spent with the project. I do think decoupling your frontend from your backend is still best practice, but if you need to spin up a project with a good frontend and don’t care about decoupling, then you should 100% check this project out. 我希望看到人们更多地尝试一下这个框架并看到它的能量。由于我在这个项目中花费的时间有限,我可能无法在这里做到公正。但我确实认为,将前端与后端解耦仍然是最佳实践,但是如果你需要启动一个具有良好前端的项目并且不关心是否解耦,那么你百分百应该试一下这个项目。
Very cool project, and would recommend anyone check it out if they like Hardhat and Truffle but want to integrate with a full-stack solution. 这个项目很酷,如果有人喜欢Hardhat和Truffle,但又想与全栈解决方案集成,非常推荐尝试一下这个项目。 Summary**
总结
Now before I proceed with some alternatives to the above, I wanted to take a quick break and point out some important non-framework tools for 2021.
现在,在继续陈述上述框架之外的备选方案之前,我想先暂停一下,并指出2021年的一些重要的非框架类工具。
OpenZeppelin is a platform that creates tools for smart contract engineers to use. They have some defaults, like ERC20 and ERC721 tools, where you can just import their contract and have a token built in seconds. Look how simple it is to make an ERC20 with OpenZeppelin: OpenZeppelin是一个平台,它为智能合约工程师们创建了方便使用的工具。他们有一些默认配置,例如ERC20和ERC721工具,你可以在其中导入他们的合约并在几秒钟内建立一个代币合约。看看用OpenZeppelin创建ERC20代币合约有多简单:
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 {
constructor(uint256 initialSupply) public ERC20(“Gold”, “GLD”) {
_mint(msg.sender, initialSupply);
}
}
It doesn’t make sense to reinvent the wheel. OpenZeppelin is an open source project dedicated to making sure you don’t have to. 重新发明轮子没有意义。OpenZeppelin是一个开源项目,致力于确保开发者无需重复造轮子。
The other huge piece OpenZeppelin has is their upgradable contracts functionality. Deploying a working project means you’ll have to deploy a proxy contract that you’ll need to update whenever you want to make changes. This is another project that feels amazing and clean. Honestly, every project, no matter what platform you’re using, should probably use something OpenZeppelin has created at some point. OpenZeppelin的另一个重要组成是它的可升级合约功能。部署一个正在运行的项目意味着你必须部署一个代理合约,该合约在你想要执行修改时进行更新。这是另一个让人感到惊奇和干净的项目。坦白地说,每个项目,无论你使用什么平台,可能都应该在某个时候使用OpenZeppelin创建的工具。
Etherscan is the most popular block explorer. When people want to check out your contract and what you’ve deployed, they won’t be able to unless they have the ABI and contract address. Finding the contract address is usually pretty easy, but it’s a lot hard to get the ABI. You’ll want people to easily be able to see and interact with your smart contract, so you always want to verify it so others can do just that. Most frameworks have some sort of verification plugin where you can deploy a smart contract and then right after verify it on Etherscan. Be sure to use this in your applications. Etherscan是最受欢迎的区块浏览器。当人们想要查看你的合约以及你已部署的内容时,除非他们有ABI和合约地址,否则他们将无法执行。找到合约地址通常很容易,但是要获得ABI却很困难。如果希望人们能够轻松地查看你的智能合约并与之交互,你会想要合约被验证,以便他人可以查看合约或交互等。大多数框架都有某种验证插件,你可以在其中部署智能合约,然后在Etherscan上进行验证。确保在你的应用程序中使用了这个插件。
Having a plethora of backend smart contracts is great, but if no one can use your dApp, it’s worthless. create-eth-app is a platform that allows you to spin up a frontend for your smart contracts using ReactJS. It uses a lot of newer React tricks, like state Hooks, and makes building really powerful frontends easier.
在项目背后拥有大量的智能合约是很酷的事情,但是如果没有人可以使用你的dApp,它将毫无价值。create-eth-app
是一个平台,允许你使用ReactJS为智能合约增加前端。它使用了很多新的React技巧,例如状态钩子,它让构建真正强大的前端变得容易许多。
I’m not going to go into what these do here, but if you’re new to the space, check these out! 我不会在这里介绍它们是干什么的,但是如果你是初学者,请查看它们!
The rest of these frameworks are not bad at all, and may work for you. Some of them do have some really cool ideas on what to put into a smart contract framework, and I hope the main three take note of some of these awesome ideas. These are tools that probably could use a little more exploring time. 剩下几个框架也不错,可能对你也有用。这些框架里有几个对应该将什么内容加入到智能合约框架中确实有一独到的见解,我希望头部的三个框架能注意到它们的这些很棒的想法。下面几个是可能会花费我们更多的探索时间的工具。
Image source: Waffle 图片来源: Waffle
Waffle can be used as a deployment framework itself, although you’ll have to write a lot more of your own custom scripts. It’s listed as a smart contract framework, although it feels a little silly to compare it to these other frameworks. Waffle can be used with whatever framework you like and is currently the default tool for working with Hardhat. Waffle本身可以用作部署框架,虽然你得编写更多的自定义脚本。它被列为智能合约框架,但与其他框架进行比较却有点傻。Waffle可以与你喜欢的任何框架一起使用,并且当前是Hardhat的默认工具。
I don’t recommend using this by itself if you want all the nice features a framework can provide, but if you want to work with a more raw, simple, customizable framework, you can’t go wrong here. 如果你希望的是一个框架能提供所有不错的特性,那么我不建议单独使用它,但是如果你想使用更原生,更简单,更加可自定义的框架,那么选择它一定不会错。
Summary
总结
Image source: Dapp.Tools 图片来源:Dapp.Tools
Dapp.Tools is used by MakerDAO and surprised me. It’s written in Haskell but has support for a lot of the plugins, like OpenZeppelin, that we use and love. It looks to be a minimalist framework that is powerful enough to do what you want it to do. I was able to get help in deploying my contract with this platform and was surprised by how clean and simple it was. If you’re looking for a minimalist command-line-friendly framework, then I’d recommend checking this one out as well. 让我感到惊讶的是MakerDAO使用了Dapp.Tools。它采用Haskell编写,但支持许多我们常用的和喜欢的插件,例如OpenZeppelin。它看起来像一个极简主义的框架,功能强大到足以执行你想要的任何操作。我在使用此平台部署合约时能够获得帮助,并且对它的简洁性感到惊讶。如果你正在寻找一个简化的命令行友好的框架,那么我建议你也试试这个工具。
Summary
总结**
Image source: Epirus 图片来源:Epirus
Even though I said it’s “Truffle-like,” Epirus is not very Truffle-like at all in style, but in the business sense. They have an open source project, but they have a paid upgraded tool for those looking to work more with it. They use Java’s Web3 implementation, and it looks like it’s still early in the project's development. I was happy to see they had Android support, so I’m really curious to see how this project progresses. We could get more Java engineers into the industry, as there are not many Java smart contract platforms. 虽然我说它像“Truffle”,但从风格上Epirus并不很像Truffle,而是在商业意义上的相似。他们有一个开源项目,但也有一个付费的升级工具,供那些希望有更多功能的人使用。他们使用Java版本的的Web3实现,而且看起来仍处于项目开发的早期阶段。我很高兴看到他们支持Android,因此我很想知道这个项目的进展情况。由于Java智能合约平台不多,我们可以吸引更多的Java工程师进入这个行业。
I wasn’t able to deploy to Kovan as it’s not supported, but it looks like they have support for Rinkeby. In any case, I’m excited to see the project move along. 我没能部署到Kovan,因为它还不支持,但看起来他们已经支持Rinkeby。无论如何,我很高兴看到这个项目进展顺利。
Summary
总结
sbt-ethereum
One of the more interesting projects I played with, SBT focuses on interacting with smart contracts almost solely from the command line, or with Scala. I have almost zero Scala experience, so I don’t have a great standpoint from which to review this platform. It seems like it could be really cool if you know Scala and are looking to get into Ethereum. 这是我玩过的比较有趣的项目之一,SBT专注于几乎完全通过命令行或通过Scala进行智能合约交互。我几乎没有Scala相关经验,因此我没有很好的立场来评估该平台。如果你了解Scala并且像加入以太坊生态,这可能是很酷的工具。
Summary
总结
You’ll see these pop up from time to time. I’m sure they were great when they came out, but at this time, they are either no longer supported or are inactive. These will be the ones to avoid to save yourself the trouble of trying to work with them. 你会不时地看到这些框架的出现。我敢肯定,当它们刚诞生时,它们是很不错的,但目现在它们不再受到支持或处于非活跃状态。这些是你在开发时需要避免使用的工具,以免使用它们需要遇到麻烦。
Image source: OpenZeppelin SDK 图片来源:OpenZeppelin SDK
Now I understand why this project stopped working on this — as a team, they want to focus on the hard problem of upgradeable smart contracts — but to be honest, it’s sort of a shame. This project is just plain clean. I was able to deploy my Chainlinked smart contract and read the price of ETH quicker than with almost any other framework. It also had some really nice CLI options, which it looks like Epirus and Hardhat have as well. It also comes built in with upgradeable options, which is huge in a world where so few platforms do. 现在我理解了为什么这个项目方停止维护这个项目了--作为一个团队,他们希望专注于可升级的智能合约这一难题,但是老实说,有点可惜。这个项目很干净。相比于任何其他框架,借助它我能更快地部署Chainlinked智能合约来读取ETH的价格。它还具有一些非常不错的CLI选项,就像Epirus和Hardhat一样。它还内置了可升级的选项,这在很少有平台会这样做的世界里独树一帜。
I don’t recommend using this, as they intentionally are not supporting it anymore, but this was one of the best developer experiences I’ve had with a smart contract framework. I hope the main three are able to pick up on what made this project so shiny. There is a reason why I said above that everyone should use OpenZeppelin tools. They just work. 我不建议使用这个工具,因为他们有意不再支持它了,但这是给了我最佳开发者体验的智能合约框架之一。我希望前三名的框架能够从中汲取使该项目如此光彩夺目的灵感。我前面说过,每个人都应该使用OpenZeppelin工具是有原因的。它们就是好用。
If they didn’t stop working on this, their SDK would easily be a top-four framework. 如果他们不停止这项工作,那么他们的SDK很容易成为前四名的框架。
Summary
总结
Image source: Etherlime 图片来源: Etherlime
Etherlime seems to be another JS framework that is falling out of favor and not being actively worked on. It’s tightly coupled with an outdated feature of Infura, so we weren’t able to deploy our smart contracts on Kovan. It seems like it was a really strong project when it was alive, and it looks like it still works for local development, but I wouldn’t recommend it over the top three. Etherlime看起来是另一个不受青睐且团队不积极工作的JS框架。它与Infura的过时特性紧密结合,因此我们无法在Kovan上部署智能合约。在它活跃的时候这是一个非常强大的项目,而且看起来现在仍然可以用于本地开发,但是我不建议在前三名框架中使用它。
Summary
总结
Image source: Parasol 图片来源:Parasol
Another inactive JS framework (over two years without a commit). It has some cool features, like parasol interact
, and some integrations, and clearly, some really intelligent people worked on this, but I see no reason to use this platform over any of the other JS frameworks.
另一个不再活跃的JS框架(超过两年未提交新代码)。它具有一些很酷的功能,例如parasol interact
以及一些集成,并且显然的是,有一些真正聪明的人在为这个项目工作,但是现在我认为没有理由在任何其他JS框架上使用该平台。
Summary**
总结
The smart contract and blockchain world moves fast. Some of the hottest tools from two years ago are already old news, and smart contract development frameworks are no different. It’s cool to see Truffle stay at the top of the game, but even greater is that so many projects have taken a different approach to the problem. 智能合约和区块链世界发展迅速。两年前的一些最热门的工具现在已经过时了,智能合约开发框架也是如此。很酷的是看到Truffle始终处于游戏的顶端,但更好的事情在于,许多项目采用了不同的方法来解决这个问题。
If you think I missed one or got it wrong, or you have some other thoughts, feel free to leave a comment or reach out. The idea here is to enable smart contract engineers to get started as quickly and as effectively as possible. Shedding light on all the tools will allow us to reach that point where the world is decentralized faster. Hope this was helpful! 如果你认为我错过了某个框架或者说错了某个框架,或者你有其他的想法,请随时发表评论或联系我。这里的想法是使智能合约工程师能够尽快有效地入门。将所有的工具讲清楚有助于我们达到更快地实现世界去中心化的状态。希望这对你有所帮助!
本文首发于:https://medium.com/better-programming/the-top-blockchain-developer-frameworks-for-2021-89afa5e7bd04
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!