1. 开发者快速上手 (Developer Quickstart)

This guide will walk developers through writing a smart contract in Sway, a simple test, deploying to Fuel, and building a frontend.

本手册将指导开发人员在 Sway 中编写智能合约、进行简单测试、部署到 Fuel 以及构建前端。

Before we begin, it may be helpful to understand the terminology that will be used throughout the docs and how they relate to each other:

在我们开始之前,提前了解在整个文档中使用的术语和它们之间的相互关系,会有所帮助:

  • Fuel: the Fuel blockchain. Fuel:Fuel 区块链。

  • FuelVM: the virtual machine powering Fuel. FuelVM:为 Fuel 提供支持的虚拟机。

  • Sway: the domain-specific language crafted for the FuelVM; it is inspired by Rust. Sway:为 FuelVM 打造的特定领域语言;它的灵感来自 Rust。

  • Forc: the build system and package manager for Sway, similar to Cargo for Rust. Forc:Sway 的构建系统和包管理器,类似于 Rust 的 Cargo。

了解 Sway 程序类型 (Understand Sway Program Types)

There are four types of Sway programs: 有四种类型的 Sway 程序:

  • 合约 contract

  • 谓词 predicate

  • 脚本 script

  • 库 library

The main features of a smart contract that differentiate it from scripts or predicates are that it is callable and stateful.

智能合约区别于脚本或谓词的主要特征是它是可调用的和有状态的。

A script is runnable bytecode on the chain which can call contracts to perform some task. It does not represent ownership of any resources and it cannot be called by a contract.

脚本是链上可运行的字节码,可以调用合约来执行某些任务。它不代表任何资源的所有权,也不能被合约调用。

See the chapter on program types for more information.

有关详细信息,请参阅有关程序类型的章节。

A few pieces of info that will be helpful before moving on:

在继续之前,还有一些有用的信息:

  • This guide was created using VSCode as the code editor. 本手册是使用 VSCode 作为代码编辑器创建的。

  • Download the Sway language extension in VSCode to get syntax highlighting, keyboard shortcuts, and more. 在 VSCode 中下载 Sway 语言扩展,可以获得语法高亮显示、键盘快捷键等。

  • Download the rust-analyzer extension in VSCode to get syntax highlighting, code completion, and more. 下载 VSCode 中的 rust-analyzer 可以获得语法高亮、代码完成等功能。

Last updated