11.如何运行spark当地节点 (How to run spark on the local node)

Local node accounts private keys 本地节点账号私钥

ADMIN=806e4997e9f54373564eae2da8b28f3f184e91bb0409ec1c9c38740465dceb71
ALICE=0da41b477ec84d3569179e48e608d5b3e5a2f7dab24be1ca0cd0da42e5e42781
BOB=39a33b415866e48a8a600df88af0759baaff001669a8938eebfc9641c1be25bd

Setting up a local Fuel network

  1. Clone the Spark repository by running the command: 运行以下命令克隆 Spark 存储库:

git clone git@github.com:compolabs/spark.git
  1. Navigate to the cloned repository directory by running: 运行以下命令导航到克隆的存储库目录:

cd spark
  1. Switch to the local-node branch by running: 运行以下命令切换到“local-node”分支:

git checkout local-node
  1. Start a local Fuel node by navigating to the node directory and running the command: 运行以下命令来导航到node目录并启动本地 Fuel 节点:

cd node && fuel-core run --ip 127.0.0.1 --port 4000 --chain ./chainConfig.json --db-path ./.fueldb

This will start a local node running on your machine. 这将启动在您的计算机上运行的本地节点。

部署代币和限价订单合约 (Deploying Token and Limit Order Contracts)

  1. Open new terminal 打开新终端

  2. Navigate to the contracts/token directory and create an .env file with the following content: 导航到contracts/token目录并创建一个包含以下内容的.env文件:

echo "SECRET=806e4997e9f54373564eae2da8b28f3f184e91bb0409ec1c9c38740465dceb71" >> .env 

This sets the private key of the account used to deploy the contracts.

这会设置用于部署合约的帐户的私钥。

  1. Build the contracts by running the command: 通过运行命令构建合约:

forc build
  1. Deploy the Token contract by running the command: 通过运行命令部署代币合约:

cargo test --package tests --test tests -- actions::deploy::deploy --exact --nocapture
  1. Navigate to the contracts/limit_orders directory and build the Limit Order contract by running the command: 导航到contracts/limit_orders目录并通过运行以下命令构建限价订单合约:

forc build
  1. Deploy the Limit Order contract by running the command: 通过运行以下命令部署限价订单合约:

forc deploy --unsigned

运行前端 (Running the Frontend)

  1. Navigate to the frontend directory and install the required packages by running the command: 导航到frontend目录并通过运行以下命令安装所需的包:

npm i
  1. Start the frontend by running the command: 通过运行以下命令启动前端:

npm start

This will start the frontend in your default browser. 这将在您的默认浏览器中启动前端。

运行图表数据推送后端 (Running the Chart Data Feed Backend)

  1. Open new terminal 打开新终端

  2. Unfortunately, we do not yet have instructions on how to launch the backend data feed due to the trading view privacy policy. But you can contact us and we will help you launch a lightweight trading view chart. 不幸的是,由于交易视图隐私政策,我们还没有关于如何启动后端数据推送的说明。但是您可以联系我们,我们会帮您推出轻量级交易视图图表

运行匹配者服务 (Running the Matcher Service)

15.Navigate to the services/matcher directory and create an .env file with the following content: 导航到services/matcher目录并创建一个包含以下内容的.env文件:

echo "SECRET=806e4997e9f54373564eae2da8b28f3f184e91bb0409ec1c9c38740465dceb71" >> .env 

This sets the private key of the account used to deploy the contracts. 这会设置用于部署合约帐户的私钥。

  1. Run the Matcher service by running the command: 通过运行以下命令运行 匹配者Matcher 服务:

cargo run

This will start the Matcher service in your terminal. 这将在您的终端中启动 Matcher 服务。

That's it! You should now have a local Fuel network running with the Token and Limit Order contracts deployed, the frontend running in your browser, and the Matcher service running in your terminal.

就是这样!您现在应该有一个本地 Fuel 网络运行,其中部署了代币和限价订单合约,前端在您的浏览器中运行,Matcher 服务在您的终端中运行。

测试 (Testing)

To test the frontend, you can connect Alice's or Bob's wallet (which are given at the beginning of this tutorial), they will have ETH on their balance to pay fees

要测试前端,您可以连接 Alice 或 Bob 的钱包(在本教程开头给出),他们的余额中将有 ETH 来支付费用

Last updated