基于区块链的毕业设计Ethereum APIs – 以太坊API

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Ethereum APIs – 以太坊API 是一篇很好的国外资料

Ethereum APIs

Ethereum APIs - <a href=以太坊ethAPI”> Ethereum APIs - <a href=以太坊ethAPI”> Ethereum APIs - <a href=以太坊ethAPI”> Ethereum APIs - <a href=以太坊ethAPI”>

This repository hosts Prysm’s service interface definitions for the Ethereum 2.0 API. These protocol buffer service definitions support gRPC as well as JSON over HTTP.

Need assistance?

More indepth descriptions of each service are available in this section of our official documentation. For more general information on the functionality of gRPC and protocol buffers, see the gRPC guide. If you still have questions, feel free to stop by either our Discord or Gitter and a member of the team or our community will be happy to assist you.

Service definitions

Package Service Version Description
eth BeaconChain v1alpha1 This service is used to retrieve critical data relevant to the Ethereum 2.0 phase 0 beacon chain, including the most recent head block, current pending deposits, the chain state and more.
eth Node v1alpha1 The Node service returns information about the Ethereum node itself, including versioning and general information as well as network sync status and a list of services currently implemented on the node.
eth Validator v1alpha1 This API provides the information a validator needs to retrieve throughout its life cycle, including recieved assignments from the network, its current index in the state as well as the rewards and penalties that have been applied to it.

Contributing

Thanks for wanting to contribute to our eth2 API! Go libraries may be generated from the ethereumapis repository using Bazel, making it easy to make changes to the schemas needed and generate Go files from them. Here’s what you need to get started:

Dependencies

  • A modern, UNIX operating system
  • The latest release of Bazel installed
  • The cmake package installed
  • The git package installed

Making API Schema Changes

Say you want to add a new endpoint to the BeaconChain gRPC service in our API schema to retrieve orphaned blocks. First, make sure the functionality you wish to add is not already covered by one of our endpoints on https://api.prylabs.network. Also, keep in mind making strict changes to the API schema can often times be difficult without a significant reason as this API is used by many different developers building on eth2. If you are confident in your desired changes, you can proceed by modifying the protobuf schema:

service BeaconChain {     // Retrieve orphaned blocks from the eth2 chain.     rpc GetOrphanedBlocks(OrphanedBlocksRequest) returns (OrphanedBlocksResponse) {         option (google.api.http) = {             get: "/eth/v1alpha1/beacon/blocks/orphaned"         };     }     ... }  message OrphanedBlocksRequest {     uint64 slot = 1; }  message OrphanedBlocksResponse {     repeated BeaconBlock blocks = 1; }

After making your changes, you can regenerate the Go libraries from the schema by running:

$ ./scripts/update-go-pbs.sh

Then, open a pull request with your changes on https://github.com/prysmaticlabs/ethereumapis. Next, you’ll be ready to implement your new changes in Prysm itself.

Implementing Your Changes in Prysm

Ensure you have read our contribution guidelines first. Then, once your changes to the API schema are merged into the master branch of ethereumapis, you can update Prysm’s dependency on ethereumapis to its latest version with the command:

$ bazel run //:gazelle -- update-repos github.com/prysmaticlabs/ethereumapis

Prysm also utilizes generated mocks for testing gRPC requests/responses, so you will also need to regenerate the required mocks by running:

$ ./scripts/update-mockgen.sh

Now, you will be able to implement your required changes in Prysm.

RESTful endpoints (gRPC Transcoding)

All of the gRPC services should define JSON over HTTP endpoints by specifying HTTPRules. Developers may choose to bundle a REST service of gRPC with their client implementation binaries, or alternatively, they may use a JSON encoding proxy such as Envoy Proxy, grpc-gateway, etc.

For more information on gRPC transcoding, see the examples found here.

Code sample:

service Messaging {     rpc GetMessage(GetMessageRequest) returns (Message) {         option (google.api.http) = {             get: "/v1/{name=messages/*}"         };     } } message GetMessageRequest {     string name = 1; // Mapped to URL Path. } message Message {     string text = 1; // The resource content. } 

This enables an HTTP REST to gRPC mapping, as shown below:

HTTP gRPC
GET /v1/messages/123456 GetMessage(name: "messages/123456")

JSON mapping

The majority of field primitive types for Ethereum are either bytes or uint64. The canonical JSON mapping for those fields are a Base64 encoded string for bytes, or a string representation of uint64. Since JavaScript loses precision for values over MAX_SAFE_INTEGER, uint64 must be a JSON string in order to accommodate those values. If the field value not changed and is still set to protobuf’s default, this field will be omitted from the JSON encoding entirely.

For more details on JSON mapping for other types, view the relevant section in the proto3 language guide.

gRPC tooling and resources

  • Awesome gRPC
  • Google’s API Style Guide
  • Language reference for protoc3
  • Protocol Buffer Basics: Go
  • Transcoding gRPC to JSON/HTTP using Envoy

License

Apache 2.0

ETH2 Types: Epoch (


服务定义

Ethereum APIs - <a href=以太坊ethAPI”>Ethereum APIs - <a href=以太坊ethAPI”>Ethereum APIs - <a href=以太坊ethAPI”>Ethereum APIs - <a href=以太坊ethAPI”>

此存储库为以太坊eth2.0 API托管Prysm的服务接口定义。这些协议缓冲区服务定义支持gRPC以及HTTP上的JSON。

贡献

有关每项服务的详细说明,请参阅我们官方文档的本节。有关gRPC和协议缓冲区功能的更多常规信息,请参阅gRPC指南。如果您仍有疑问,请随时访问我们的Discord或Gitter,我们的团队或社区成员将很乐意为您提供帮助。

依赖项

Package Service Version Description
v1alpha1 此服务用于检索与以太坊eth2.0 phase 0信标链相关的关键数据,包括最新的头块、当前未决存款、链状态等。 eth 节点
节点服务返回有关以太坊eth节点本身的信息,包括版本控制和常规信息、网络同步状态以及节点上当前实现的服务列表。 eth 验证程序
此API提供验证程序在其整个生命周期中需要检索的信息,包括从网络接收的分配、其当前状态的索引以及对其应用的奖惩。 GET/v1/messages/123456 GetMessage(名称:“messages/123456”) This API provides the information a validator needs to retrieve throughout its life cycle, including recieved assignments from the network, its current index in the state as well as the rewards and penalties that have been applied to it.

进行API架构更改

感谢您为我们的eth2 API做出贡献!Go库可以使用Bazel从ethereumapi存储库生成,这样就可以方便地更改所需的模式并从中生成Go文件。下面是您需要开始的内容:

实现Prysm中的更改

  • 一个现代的UNIX操作系统
  • The latest release of Bazel installed
  • The cmake package installed
  • The git package installed

RESTful端点(gRPC转码)

假设您想在我们的API模式中向BeaconChain gRPC服务添加一个新端点,以检索孤立块。首先,确保您要添加的功能尚未包含在上的某个端点中https://api.prylabs.network。另外,请记住,对API模式进行严格的更改通常是很困难的,因为许多构建在eth2上的不同开发人员都使用这个API。如果您对所需的更改有信心,可以通过修改protobuf模式继续进行:

service BeaconChain {     // Retrieve orphaned blocks from the eth2 chain.     rpc GetOrphanedBlocks(OrphanedBlocksRequest) returns (OrphanedBlocksResponse) {         option (google.api.http) = {             get: "/eth/v1alpha1/beacon/blocks/orphaned"         };     }     ... }  message OrphanedBlocksRequest {     uint64 slot = 1; }  message OrphanedBlocksResponse {     repeated BeaconBlock blocks = 1; }

进行更改后,可以通过运行:

$ ./scripts/update-go-pbs.sh

从模式重新生成Go库,然后打开一个带有更改的pull请求https://github.com/prysmaticlabs/ethereumapi。接下来,您将准备在Prysm本身中实现新的更改。

JSON映射

请确保您先阅读了我们的投稿指南。然后,一旦您对API模式所做的更改被合并到EthereumAPI的主分支中,您就可以使用以下命令将Prysm对EthereumAPI的依赖关系更新到最新版本:

$ bazel run //:gazelle -- update-repos github.com/prysmaticlabs/ethereumapis

Prysm还使用生成的模拟来测试gRPC请求/响应,因此您还需要通过运行以下命令重新生成所需的模拟:

$ ./scripts/update-mockgen.sh

Now,您将能够在Prysm中实现所需的更改。

gRPC工具和资源

所有gRPC服务都应该通过指定HTTPRules来定义HTTP端点上的JSON。开发人员可以选择将gRPC的REST服务与其客户机实现二进制文件捆绑在一起,或者,他们可以使用JSON编码代理,如特使代理、gRPC网关等。

有关gRPC转码的更多信息,请参阅此处的示例。

代码示例:

service Messaging {     rpc GetMessage(GetMessageRequest) returns (Message) {         option (google.api.http) = {             get: "/v1/{name=messages/*}"         };     } } message GetMessageRequest {     string name = 1; // Mapped to URL Path. } message Message {     string text = 1; // The resource content. } 

这将启用HTTP REST到gRPC的映射,如下所示:

HTTP gRPC
GET /v1/messages/123456 GetMessage(name: "messages/123456")

许可证

以太坊eth的大多数字段原语类型是bytes或uint64。这些字段的规范JSON映射是字节的Base64编码字符串,或uint64的字符串表示。由于JavaScript会丢失超过MAXu SAFEu INTEGER的值的精度,uint64必须是JSON字符串才能容纳这些值。如果字段值没有改变并且仍然设置为protobuf的默认值,那么这个字段将从JSON编码中完全省略。

有关其他类型的JSON映射的详细信息,请查看proto3语言指南中的相关部分。需要帮助吗?

服务定义

贡献

依赖项

进行API架构更改

实现Prysm中的更改

RESTful端点(gRPC转码)

JSON映射

gRPC工具和资源

许可证

  • 一个现代的UNIX操作系统
  • 安装了Bazel的最新版本安装了cmake包安装了git包使用en特使将gRPC转换成JSON/HTTPBeaconChain v1alpha1 此服务用于检索与以太坊eth2.0 phase 0信标链相关的关键数据,包括最新的头块、当前未决存款、链状态等。 eth 节点 节点服务返回有关以太坊eth节点本身的信息,包括版本控制和常规信息、网络同步状态以及节点上当前实现的服务列表。 eth 验证程序

    此API提供验证程序在其整个生命周期中需要检索的信息,包括从网络接收的分配、其当前状态的索引以及对其应用的奖惩。 GET/v1/messages/123456 GetMessage(名称:“messages/123456”)

    gRPC tooling and resources

    • Awesome gRPC
    • Google’s API Style Guide
    • Language reference for protoc3
    • Protocol Buffer Basics: Go
    • Transcoding gRPC to JSON/HTTP using Envoy

    License

    Apache 2.0

    ETH2 Types: Epoch (

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

    www.interchains.cc

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

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

    提供最优质的资源集合

    立即查看 了解详情