Ethernaut – 以太鸟区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Ethernaut – 以太鸟区块链毕设代写 是一篇很好的国外资料

Ethernaut

Ethernaut is a Web3/Solidity based wargame inspired in overthewire.org, to be played in the Ethereum Virtual Machine. Each level is a smart contract that needs to be ‘hacked’.

The game acts both as a tool for those interested in learning ethereum, and as a way to catalogue historical hacks in levels. Levels can be infinite and the game does not require to be played in any particular order.

Level PR’s are welcome!

Deployed Versions

You can find the current, official version at: ethernaut.openzeppelin.com

Running locally (local network)

  1. Install
git clone git@github.com:OpenZeppelin/ethernaut.git npm install 
  1. Start deterministic rpc
npm run ganache 
  1. You might want to import one of the private keys from ganache-cli to your Metamask wallet.
  2. Compile contracts
npx truffle compile 
  1. Set src/constants.js ACTIVE_NETWORK to NETWORKS.LOCAL
  2. Deploy contracts
npm run deploy:contracts 
  1. Start react client
npm start 

Running locally (ropsten network)

The same as using the local network but steps 2, 3 and 6 are not necessary.

In this case, replace point 5 with: 5. Set src/constants.js ACTIVE_NETWORK to NETWORKS.ROPSTEN

Running tests

npx truffle test 

Level development

A level is composed of the following elements:

  • A level factory contract that needs to extend Level.sol. This factory contract will be deployed only once and registered on Ethernaut.sol by Ethernaut’s owner. Players never interact with the factory directly. The factory is in charge of creating level instances for players to use (1 instance per player) and to check these instances to verify if the player has beat the level. Factories should not have state that can be changed by the player.
  • A level instance contract that is emitted by the factory for each player that requests it. Instances need to be completely decouppled from Ethernaut’s architecture. Factories will emit them and verify them. That is, level instances don’t know anything about their factories or Ethernaut. An instance’s state can be completely demolished by players and even destroyed since they are not really part of the architecture, just a challenge for a player to use at will.
  • A description file in gamedata/descriptions that the UI presents to the player and describes the level’s objectives with some narrative and tips.
  • A description completion file also in gamedata/descriptions that the UI presents to the player when the level is beaten, that presents further information about the player, historical insights, further explanations or just a congrats message.
  • A tests file in test/levels that performs unit tests on the level.
  • A json entry for the level in gamedata/gamedata.json that appends metadata to the level. The UI uses this metadata to display the level’s title, difficulty, etc, but also to determine if sources are shown, the default gas for the creation of an instance, etc. NOTE: “deployId” must be unique and is also used by the deployment script.
  • Optionally, an author entry at gamedata/authors.json. You can specify opt-in information about yourself in this file.

Example level development: King

Let’s suppose that we are creating the level “King” (which is already created and available in the game of course).

  1. Fork this repo, clone and npm install.
  2. Use the other levels as a basis, eg. duplicate DummyFactory.sol and Dummy.sol.
  3. Rename and modify the contracts to KingFactory.sol and King.sol.
  4. Implement the desired instance and factory logic in solidity. See current levels and notes to understand how the game mechanics work.
  5. Add test/levels/King.test.js file. Use other tests files as reference to see how tests might work.
  6. Run truffle test and once all tests pass, register the level in gamedata/gamedata.json.
  7. The level should now show up in the ui. To start the UI, set src/constants.js’ ACTIVE_NETWORK to DEVELOPMENT and run npm start.
  8. Add a description markdown file, in this case gamedata/levels/king.md (make sure gamedata.json points to it). This content will now be displayed in the ui for the level.
  9. Verify that the level is playable and winnable via UI. It is common for levels to be beatable in some way in tests that doesn’t work using the UI, so it is important to test it manually as well.
  10. Add a completed description markdown file, in this case gamedata/levels/king_complete.md (make sure gamedata.json points to it). The level will display this as additional info once the level is solved, usually to include historical information related to the level.
  11. Make a PR request so that we can re-deploy the game with the new level!

Deployment

To deploy the react app use npm run deploy:ui. Of course, you will need ssh credentials for this.

To deploy the contracts on ropsten, first set the ACTIVE_NETWORK variable in constants.js and then edit gamedata.json. This file keeps a history of all level instances in each level data’s deployed_ropsten array. To deploy a new instance, add an “x” entry to the array, like so:

"deployed_ropsten": [   "x",   "0x4b1d5eb6cd2849c7890bcacd63a6855d1c0e79d5",   "0xdf51a9e8ce57e7787e4a27dd19880fd7106b9a5c" ], 

Then run npm run deploy:contracts. This action will effectively deploy a new version of the level data item whose deployed_ropsten array was updated, and will point the ethernaut dapp to use this new deployed contract instance for the level.

We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Learn more.


部署的版本

Ethernaut是一款基于Web3/Solidity的战争游戏,灵感来源于overthewire.org网站,将在以太坊eth虚拟机中播放。每个关卡都是一个智能合约,需要被“黑”掉。

这个游戏既可以作为那些有兴趣学习以太坊eth的工具,也可以作为一种分类历史黑客的方式。级别可以是无限的,游戏不需要以任何特定的顺序进行。

欢迎高级公关!

在本地运行(本地网络)

您可以在以下网址找到当前的官方版本:ethernaut.openzeppelin.com网站

在本地运行(ropsten网络)

  1. 安装
git clone git@github.com:OpenZeppelin/ethernaut.git npm install 
  1. 启动确定性rpc
npm run ganache 
  1. 您可能需要将其中一个私钥从ganache cli导入到Metamask钱包中。
  2. 编译合同
npx truffle compile 
  1. 设置src/常量.js主动网络到网络.本地
  2. 部署契约
npm run deploy:contracts 
  1. 启动react client
npm start 

运行测试

与使用本地网络相同,但不需要步骤2、3和6。

在这种情况下,将第5点替换为:5。设置src/常量.js主动网络到网络.ROPSTEN

级开发

npx truffle test 

示例级开发:King

一个关卡由以下元素组成:

  • 需要扩展的level factory契约电平.sol. 此工厂合同将只部署一次并在上注册乙醚钠以太诺特的主人。永远不要与玩家直接互动。工厂负责创建级别实例供玩家使用(每个玩家1个实例),并检查这些实例以验证玩家是否已超过级别。工厂不应该有可以被玩家改变的状态。
  • 工厂为每个请求它的玩家发出的级别实例契约。实例需要完全从Ethernaut的架构中剥离出来。工厂会排放并核实。也就是说,级别实例对它们的工厂或Ethernaut一无所知。一个实例的状态可以被玩家完全摧毁,甚至被摧毁,因为它们并不是体系结构的一部分,只是玩家随意使用的一个挑战。
  • 游戏数据/描述中的一个描述文件,用户界面向玩家展示,并用一些叙述和提示描述关卡的目标。
  • 游戏数据/描述中的一个描述完成文件,当关卡被击败时,用户界面会显示给玩家,显示关于玩家的更多信息、历史见解、进一步的解释或者仅仅是一条祝贺信息。
  • test/levels中对该级别执行单元测试的测试文件。
  • gamedata中级别的json条目/游戏数据.json将元数据附加到级别。UI使用此元数据来显示级别的标题、难度等,但也用于确定是否显示源、创建实例的默认气体等。注意:“deployId”必须是唯一的,并且也由部署脚本使用。
  • 可选,gamedata中的作者条目/作者.json. 您可以在此文件中指定有关您自己的选择加入信息。

部署

让我们假设我们正在创建一个关卡“王”(当然,这个关卡已经创建并在游戏中可用)。

  1. 派生此repo、clone和npm安装。
  2. 使用其他级别作为基础,例如复制杜米工厂.sol以及假人.sol.
  3. 将合同重命名并修改为金工厂.sol以及国王索尔.
  4. 可靠地实现所需的实例和工厂逻辑。查看当前关卡和注释,了解游戏机制是如何工作的。
  5. 添加测试/级别/King.test.js版文件。使用其他测试文件作为参考,查看测试如何工作。
  6. 运行truffle test并在所有测试通过后,在gamedata中注册级别/游戏数据.json.
  7. 级别现在应该显示在ui中。要启动UI,请设置src/常量.js主动网络开发和运行npm启动。
  8. 添加一个描述降价文件,在本例中是gamedata/levels/国王医学博士(确保游戏数据.json指向它)。此内容现在将显示在级别的ui中。
  9. 验证该关卡是否可通过UI播放和赢取。在使用UI无法工作的测试中,级别以某种方式被击败是很常见的,因此手动测试也很重要。
  10. 添加一个完整的描述降价文件,在本例中是gamedata/levels/king_完整.md(确保游戏数据.json指向它)。级别解决后,级别将显示为附加信息,通常包括与级别相关的历史信息。
  11. 提出公关请求,这样我们就可以用新的关卡重新部署游戏了!在

基本cookies

要部署react应用程序,请使用npm run部署:ui。当然,这需要ssh凭据。

要在ropsten上部署契约,首先在常量.js然后编辑游戏数据.json. 此文件保存每个级别数据的已部署的u-ropsten数组中所有级别实例的历史记录。要部署新实例,请向数组添加一个“x”条目,如下:

"deployed_ropsten": [   "x",   "0x4b1d5eb6cd2849c7890bcacd63a6855d1c0e79d5",   "0xdf51a9e8ce57e7787e4a27dd19880fd7106b9a5c" ], 

然后运行npm run部署:合同。此操作将有效地部署一个新版本的level数据项,其部署的_-ropsten数组已更新,并将指向ethernaut dapp将此新部署的契约实例用于该级别。

我们使用可选的第三方分析cookies来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。了解更多。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/18563.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Ethernaut – 以太鸟区块链毕设代写

提供最优质的资源集合

立即查看 了解详情