@0x/coordinator-server 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

Table of contents

Introduction

协调器的参考实现服务器。 要了解有关协调器的更多信息,请查看协调器规范。 要了解有关此实现的具体设计决策的更多信息,请阅读 设计选择部分

分叉此存储库以开始使用!

Getting started

Pre-requirements

要在 0x-coordinator-server 上开发,请按照以下说明进行操作:

  1. Fork this repository

  2. 克隆此存储库的 fork

  3. 确保你有 Yarn 安装。

  4. 安装依赖项:

    yarn
    
  5. 编辑 src/production_configs.ts 文件以与您的中继器一起使用:

  • FEE_RECIPIENTS - Should include the addresses and private keys of the feeRecipientAddress's you enforce for your orders (per chainId). Your coordinator's signatures will be generated using these private keys.
  • SELECTIVE_DELAY_MS - An optional selective delay between fill request receipt and approval. Adding a delay here can help market makers cancel orders without competing on speed with arbitrageurs.
  • EXPIRATION_DURATION_SECONDS - How long an issued signature should be valid for. This value should be long enough for someone to concievably fill an order, but short enough where off-chain cancellations take effect after some reasonable upper-bound.
  • RPC_URL - The backing Ethereum node to use for JSON RPC queries. Please add your own Infura API key if using Infura.
  1. 构建项目

    yarn build
    

    或构建 & 观看:

    yarn watch
    
  2. 启动协调器服务器

    yarn start
    

Commands

  • yarn build - Build the code
  • yarn lint - Lint the code
  • yarn start - Starts the relayer
  • yarn watch - Watch the source code and rebuild on change
  • yarn prettier - Auto-format the code

Database

该项目使用TypeORM。 它使任何人都可以更轻松地切换出该项目使用的支持数据库。 默认情况下,此项目使用 SQLite 数据库。

在将协调器部署到生产环境之前,请确保从 ormconfig.json 中删除以下行:

"synchronize": true,

否则数据库架构将在每次应用程序启动时自动创建。 在此处阅读更多内容。

Deployment

0x-coordinator-server 作为 docker 容器发布。 首先,安装 Docker (mac, windows)。 在构建映像之前,请确保您已按照先决条件 的第 5 步中的概述编辑了配置。

要构建图像运行:

docker build -t 0x-coordinator-server .

您可以通过运行检查图像是否构建:

docker images

启动它

docker run -p 3000:3000 -d 0x-coordinator-server

Legal Disclaimer

并使用适用于数字资产和区块链原生令牌的使用和交换的法律和法规 ,包括通过使用创建的许可作品开发的任何软件由 ZeroEx 国际。 如此处所述(“作品”),因司法管辖区而异。 正如适用于作品的 Apache 许可证 2.0 版中所述,开发人员“全权负责确定使用或重新分发作品的适当性”,其中包括确保遵守任何此类适用法律和法规的责任。 有关管理所有适用权限和限制的特定语言,请参阅 Apache 许可证 2.0 版:http://www.apache.org/licenses/LICENSE-2.0

Table of contents

Introduction

A reference implementation of the coordinator server. To learn more about coordinators, check out the coordinator specification. To learn more about the specific design decisions of this implementation, read the design choices section.

Fork this repository to get started!

Getting started

Pre-requirements

To develop ontop of 0x-coordinator-server, follow the following instructions:

  1. Fork this repository

  2. Clone your fork of this repository

  3. Make sure you have Yarn installed.

  4. Install the dependencies:

    yarn
    
  5. Edit the src/production_configs.ts file to work with your relayer:

  • FEE_RECIPIENTS - Should include the addresses and private keys of the feeRecipientAddress's you enforce for your orders (per chainId). Your coordinator's signatures will be generated using these private keys.
  • SELECTIVE_DELAY_MS - An optional selective delay between fill request receipt and approval. Adding a delay here can help market makers cancel orders without competing on speed with arbitrageurs.
  • EXPIRATION_DURATION_SECONDS - How long an issued signature should be valid for. This value should be long enough for someone to concievably fill an order, but short enough where off-chain cancellations take effect after some reasonable upper-bound.
  • RPC_URL - The backing Ethereum node to use for JSON RPC queries. Please add your own Infura API key if using Infura.
  1. Build the project

    yarn build
    

    or build & watch:

    yarn watch
    
  2. Start the Coordinator server

    yarn start
    

Commands

  • yarn build - Build the code
  • yarn lint - Lint the code
  • yarn start - Starts the relayer
  • yarn watch - Watch the source code and rebuild on change
  • yarn prettier - Auto-format the code

Database

This project uses TypeORM. It makes it easier for anyone to switch out the backing database used by this project. By default, this project uses an SQLite database.

Before deploying the coordinator to production, make sure to remove the following line from ormconfig.json:

"synchronize": true,

Otherwise the database schema will be auto-created on every application launch. Read more here.

Deployment

0x-coordinator-server ships as a docker container. First, install Docker (mac, windows). Before you can build the image, make sure you've edited your configs as outlined in step 5 of Pre-Requirements.

To build the image run:

docker build -t 0x-coordinator-server .

You can check that the image was built by running:

docker images

And launch it with

docker run -p 3000:3000 -d 0x-coordinator-server

Legal Disclaimer

The laws and regulations applicable to the use and exchange of digital assets and blockchain-native tokens, including through any software developed using the licensed work created by ZeroEx Intl. as described here (the “Work”), vary by jurisdiction. As set forth in the Apache License, Version 2.0 applicable to the Work, developers are “solely responsible for determining the appropriateness of using or redistributing the Work,” which includes responsibility for ensuring compliance with any such applicable laws and regulations. See the Apache License, Version 2.0 for the specific language governing all applicable permissions and limitations: http://www.apache.org/licenses/LICENSE-2.0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文