1.1 安装(Installation)
The Sway toolchain is sufficient to compile Sway smart contracts. Otherwise, note that if you want to run Sway smart contracts (e.g. for testing), a Fuel Core full node is required, which is packaged together with the Sway toolchain together as the Fuel toolchain.
Sway工具链 足以编译Sway智能合约。否则,请注意,如果你想运行Sway智能合约(例如用于测试),需要一个Fuel Core完整节点,它与 Sway工具链 一起打包为 Fuel工具链。
通过预编译的二进制文件进行安装(推荐)-Install via Pre-compiled Binaries (Recommended)
Installing via pre-compiled release binaries is the recommended way to get up and running with the Sway toolchain. Pre-compiled binaries for Linux and macOS are available. Native Windows is currently unsupported (tracking issue for Windows support). Windows Subsystem for Linux should work but is not officially supported.
使用Sway工具链启动和运行的推荐方式是通过预编译的二进制文件进行安装。Linux和macOS的预编译二进制文件已经可用。本地Windows目前不支持(跟踪Windows支持问题)。用于Linux的Windows子系统应该可以工作,但不被官方支持。
依赖 (Dependencies)
A prerequisite for installing and using Sway is the Rust toolchain. Platform-specific instructions for installing rustup
can be found here. Then, install the Rust toolchain with:
安装和使用Sway的先决条件是Rust工具链。关于安装rustup
的特定平台说明可以在这里找到。然后,用以下方法安装Rust工具链:
The Sway toolchain is built and tested against the stable
Rust toolchain version (https://github.com/rust-lang/rust/releases/latest). There is no guarantee it will work with the nightly
Rust toolchain, or with earlier stable
versions, so ensure you are using stable
with:
Sway工具链是根据stable
Rust工具链版本(https://github.com/rust-lang/rust/releases/latest)构建和测试的。不保证它能在nightly
Rust工具链或早期的 stable
版本中工作,所以要确保你使用的是stable
:
Now you're ready to install fuelup
, the equivalent of Rust's rustup
for the Fuel toolchain. It enables easily downloading binary releases of the Fuel toolchain.
现在你准备安装fuelup
,相当于Rust的 rustup
,它用于Fuel工具链。它可以轻松下载Fuel工具链的二进制版本。
Start by installing
fuelup
with the following command: 用以下命令安装fuelup
:
This downloads the fuelup-init
script to a temp directory on your machine, which installs fuelup
. fuelup-init
will ask for permission to add ~/.fuelup/bin
to your PATH. Otherwise, you can also pass --no-modify-path
so that fuelup-init
does not modify your PATH:
这将下载fuelup-init
脚本到你机器上的一个临时目录,从而安装fuelup
。fuelup-init
会要求你将~/.fuelup/bin
加入你的PATH中。当然,你也可以使用--no-modify-path
,这样fuelup-init
就不会修改你的PATH:
Once fuelup is installed, fuelup-init automatically runs
fuelup toolchain install latest
to install the latest toolchain. 一旦安装完 fuelup, fuelup-init 会自动运行fuelup toolchain install latest
来安装最新的工具链。You can run
fuelup update
at anytime to get the most up-to-date toolchain. 你可以在任何时候运行 fuelup update 来获得最新的工具链。(Optional) You can optionally install distributed toolchains optimized for different networks. (可选)你可以选择安装为不同网络优化的分布式工具链。 To configure the optimal toolchain for beta-3, run the following commands: 要配置beta-3的最佳工具链,请运行以下命令:
You're all set to start building! 现在你已经准备好开始构建了!
需要帮助? (Need Help?)
You may refer to The Fuelup Book for an in-depth look into fuelup, or check out the tooling section in the Fuel forum if you're running into problems through the installation process. If you don't see your question, post the issue you're running into with as many details as possible and the team will get back to you asap!
如果你在安装过程中遇到问题,可以参考Fuelup Book来深入了解fuelup,或者查看Fuel 论坛中的工具部分。如果你没有看到你的问题,请把你遇到的问题和尽可能多的细节贴出来,我们的团队会尽快给你答复!
从Cargo中安装 (Installing from Cargo)
The Sway toolchain and Fuel Core full node can be installed from source with Cargo with:
Sway工具链和Fuel Core全节点可以通过Cargo从源码安装:
从Cargo中更新forc
(Updating forc
from Cargo)
You can update the toolchain from source with Cargo with:
你可以用Cargo从源代码中更新工具链:
从Cargo中安装forc插件 (Installing forc
Plugins from Cargo)
The Fuel ecosystem has a few plugins which can be easily installed via Cargo. Fuel生态系统有一些插件,可以通过Cargo轻松安装。
Note:
forc
detects anything in your$PATH
prefixed withforc-
as a plugin. Useforc plugins
to see what you currently have installed. 注意: 作为一个插件,forc
会检测你的$PATH
中任何以forc-
为前缀的东西。使用forc plugins
来查看你目前安装了什么。
从源码安装 (Installing from Source)
Rather than installing from cargo
, the Sway toolchain can be built from a local source checkout by following instructions at https://github.com/FuelLabs/sway. The Fuel Core full node implementation can be built from source by following instructions at https://github.com/FuelLabs/fuel-core.
与其从 cargo
安装,Sway工具链可以按照https://github.com/FuelLabs/sway的说明,从本地源码签出来构建。Fuel Core的全节点实现可以按照https://github.com/FuelLabs/fuel-core的说明从源码中构建。
启用Bash、Fish、Zsh或PowerShell的标签完成功能 (Enable tab completion for Bash, Fish, Zsh, or PowerShell)
forc
supports generating completion scripts for Bash, Fish, Zsh, and PowerShell. See forc completions --help
for full details, but the gist is as simple as using one of the following:
forc支持为Bash、Fish、Zsh和PowerShell生成完成脚本。完整的细节见forc completions --help
,但要点是使用以下其中一个就可以了:
Once the completions have been generated and properly installed, close and reopen your terminal for the new completions to take effect.
一旦完整生成并正确安装,重启你的终端,新的安装就会生效。
Last updated