diff --git a/contentlayer.config.ts b/contentlayer.config.ts
index 07c304b4f..9e8fb57c3 100644
--- a/contentlayer.config.ts
+++ b/contentlayer.config.ts
@@ -59,6 +59,7 @@ const includeDirs = [
'docs/fuel-graphql-docs/docs',
'docs/fuels-wallet/packages/docs/docs',
'docs/guides/docs',
+ // 'docs/fuel-nix/book/src',
// 'docs/about-fuel',
];
@@ -73,6 +74,7 @@ const excludeDirs = [
'docs/fuels-rs/docs/src/SUMMARY.md',
'docs/fuel-indexer/docs/src/SUMMARY.md',
'docs/fuel-specs/src/SUMMARY.md',
+ // 'docs/fuel-nix/book/src/SUMMARY.md',
];
export default makeSource({
diff --git a/docs/guides/docs/guides.json b/docs/guides/docs/guides.json
index 254b86c22..b16353aeb 100644
--- a/docs/guides/docs/guides.json
+++ b/docs/guides/docs/guides.json
@@ -1,14 +1,18 @@
-{
- "quickstart": {
- "title": "Developer Quickstart",
- "description": "Get started by building a counter dApp in Fuel"
- },
- "running_a_node": {
- "title": "Running a Node",
- "description": "Run a local Fuel node"
- },
- "testnet_migration": {
- "title": "Testnet Migration",
- "description": "Sway and SDK's breaking changes reference"
- }
-}
+{
+ "installation": {
+ "title": "Toolchain Installation",
+ "description": "Install the Fuel toolchain and binaries."
+ },
+ "quickstart": {
+ "title": "Developer Quickstart",
+ "description": "Get started by building a counter dApp in Fuel."
+ },
+ "running_a_node": {
+ "title": "Running a Node",
+ "description": "Run a local Fuel node."
+ },
+ "testnet_migration": {
+ "title": "Testnet Migration",
+ "description": "Sway and SDK's breaking changes reference."
+ }
+}
diff --git a/docs/guides/docs/installation/codespace.mdx b/docs/guides/docs/installation/codespace.mdx
new file mode 100644
index 000000000..b0fd61e9c
--- /dev/null
+++ b/docs/guides/docs/installation/codespace.mdx
@@ -0,0 +1,73 @@
+---
+title: Fuel Github Codespace
+category: Installation
+parent:
+ label: Guides
+ link: /guides
+---
+
+# Github Codespace
+
+### Introduction
+
+The way to think about [Github Codespaces](https://github.com/features/codespaces) is essentially VSCode in a browser. It’s a remote development environment that is extremely easy to spin up. While not all VS Code plugins are supported, the Sway LSP plugin is supported and works out of the box.
+
+### How to set up for a new repo
+
+1. Create a devcontainer.json file. The easiest way is by navigating to the repo and clicking Code → … → Configure dev container
+
+
+![dev container walkthrough](/images/dev-container.gif)
+
+
+2. Edit the file to include the following features:
+
+ ```json
+ "features": {
+ "ghcr.io/devcontainers/features/common-utils:1": {},
+ "ghcr.io/FuelLabs/devcontainer-features/fuelup:1.0.1": {},
+ }
+ ```
+
+3. Add any plugins that you want to be installed for this repo under “customizations”.
+
+ ```json
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "fuellabs.sway-vscode-plugin"
+ ]
+ }
+ }
+ ```
+
+ Here are examples that include the Sway LSP plugin.
+
+ 3.1. [https://github.com/FuelLabs/sway/blob/master/.devcontainer/devcontainer.json](https://github.com/FuelLabs/sway/blob/master/.devcontainer/devcontainer.json)
+
+ 3.2. [https://github.com/FuelLabs/quickstart/blob/master/.devcontainer/devcontainer.json](https://github.com/FuelLabs/quickstart/blob/master/.devcontainer/devcontainer.json)
+
+### How to start a codespace
+
+1. Navigate to the repo that has Github Codespaces configured.
+2. Choose Code → Create codespace on master
+
+
+![Create codespace walkthrough](/images/create-codespace.gif)
+
+
+3. This will open a new tab with your codespace. It can take several minutes to start up.
+
+ 3.1. You now have a fully functional remote dev environment with the Fuel toolchain installed! You can use `forc` to build and deploy Sway code, or `fuelup` to manage the toolchain version. You also have the Sway LSP plugin with full feature support for Sway, like syntax highlighting, hover docs, go-to definitions, etc.
+
+ 3.2. Note: if you are working on a large repository and find the codespace is running slow, you can configure it to use a larger instance by clicking Code → … → change machine type on a running instance, or starting a new instance with Code → … → New with options.
+
+### Pricing & billing
+
+You will be required to enter billing information, however there is a substantial free tier.
+
+## What's next?
+
+Now you are ready to start building with Fuel.
+
+👉 Check out the [quickstart guide](/guides/quickstart) to deploy your first smart contract.
diff --git a/docs/guides/docs/installation/index.mdx b/docs/guides/docs/installation/index.mdx
new file mode 100644
index 000000000..fa1a82660
--- /dev/null
+++ b/docs/guides/docs/installation/index.mdx
@@ -0,0 +1,210 @@
+---
+title: Installation
+category: Installation
+parent:
+ label: Guides
+ link: /guides
+---
+
+# Toolchain installation
+
+This guide will help you to install the Fuel toolchain binaries and prerequisites.
+
+This guide covers the following topics:
+1. [Installing Rust](#installing-rust)
+2. [Installing the Fuel toolchain using `fuelup`](#installing-the-fuel-toolchain-using-fuelup)
+3. [Setting up a default toolchain](#setting-up-a-default-toolchain)
+
+## Installing Rust
+
+The Fuel toolchain is built on top of the Rust programming language. To install Rust, you can use the `rustup` tool.
+
+Run the following command in your shell; this downloads and runs rustup-init.sh, which in turn downloads and runs the correct version of the `rustup-init` executable for your platform.
+
+```console
+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+```
+
+Check the official Rust documentation to get more information on [installing the Rust toolchain](https://www.rust-lang.org/tools/install).
+
+## Installing the Fuel toolchain using fuelup
+
+`fuelup` is the official package manager for Fuel that installs the Fuel toolchain
+from the official release channels, enabling you to easily switch between different
+toolchains and keep them updated. It makes building and maintaining Sway applications simpler with [`forc`](docs/forc) and [`fuel-core`](https://github.com/FuelLabs/fuel-core) for common platforms.
+
+> 💡 Check out the [fuelup docs](docs/fuelup) for more information.
+
+
+### Running fuelup-init
+
+To install the Fuel toolchain, you'll use the `fuelup-init` script. This will install `forc`, `forc-client`, `forc-fmt`, `forc-lsp`, `forc-wallet` as well as `fuel-core` in `~/.fuelup/bin`.
+
+👉 Just paste the following line in your terminal and press _Enter_.
+
+```sh
+curl --proto '=https' --tlsv1.2 -sSf https://install.fuel.network/fuelup-init.sh | sh
+```
+
+> 🚧 Be aware that currently we do not natively support Windows. If you wish to use `fuelup` on Windows, please use Windows Subsystem for Linux.
+
+### Setup PATH
+
+Once the script is downloaded, it will be executed automatically. The `fuelup-init` script will prompt you with the question below:
+
+```sh
+fuelup uses "/home/username/.fuelup" as its home directory to manage the Fuel toolchain, and will install binaries there.
+
+To use the toolchain, you will have to configure your PATH, which tells your machine where to locate `fuelup` and the Fuel toolchain.
+
+If permitted, fuelup-init will configure your PATH for you by running the following:
+
+ echo "export PATH="$HOME/.fuelup/bin:$PATH"" >> /home/username/.bashrc
+
+Would you like fuelup-init to modify your PATH variable for you? (N/y)
+```
+
+👉 Press the `Y` key in your terminal and press _Enter_ to modify your PATH.
+
+### Checking the installation
+
+After allowing the `fuelup-init` script to modify your `PATH` variable, you will see a lot of information about packages being downloaded and installed. If everything goes as expected you will see the following message:
+
+```sh
+The Fuel toolchain is installed and up to date
+
+fuelup 0.19.5 has been installed in /home/username/.fuelup/bin.
+To fetch the latest toolchain containing the forc and fuel-core binaries, run 'fuelup toolchain install latest'.
+To generate completions for your shell, run 'fuelup completions --shell=SHELL'.
+```
+
+👉 Use `fuelup --version` any time to check which version of the package you are using.
+
+```sh
+ fuelup --version
+```
+That will output your current `fuelup` version:
+
+```sh
+fuelup 0.19.5
+```
+
+## Setting up a default toolchain
+
+Just as in [Rust](https://rust-lang.github.io/rustup/concepts/toolchains.html), Fuel supports multiple toolchains. A toolchain is a collection of tools (such as the compiler, lsp, etc).
+By default, `fuelup` includes a series of packages tested to work with each other, providing a reliable set of tools.
+
+In this case, we will install the `beta-4` toolchain, which is the stable toolchain compatible with the beta-4 network. For more information on `beta-4` check the [Fuel blog](https://fuel-labs.ghost.io/announcing-beta-4-testnet/) page.
+
+### Updating fuelup
+
+Make sure you have the latest version of `fuelup` so you can access the latest features and have the best performance.
+
+👉 Update `fuelup` by running the following command:
+
+```console
+fuelup self update
+```
+Then you will get an output like this:
+```console
+Fetching binary from https://github.com/FuelLabs/fuelup/releases/download/v0.19.5/fuelup-0.19.5-aarch64-apple-darwin.tar.gz
+Downloading component fuelup without verifying checksum
+Unpacking and moving fuelup to /var/folders/tp/0l8zdx9j4s9_n609ykwxl0qw0000gn/T/.tmpiNJQHt
+Moving /var/folders/tp/0l8zdx9j4s9_n609ykwxl0qw0000gn/T/.tmpiNJQHt/fuelup to /Users/.fuelup/bin/fuelup
+```
+
+### Installing the beta-4 toolchain
+
+The `beta-4` network is the latest Fuel testnet. This includes public infrastructure such as the [Beta-4 faucet](https://faucet-beta-4.fuel.network/) and the [Beta-4 GraphQL endpoint](https://beta-4.fuel.network/playground).
+
+To properly interact with the `beta-4` network it is necessary to use its corresponding toolchain.
+
+👉 Run the following command to install the `beta-4` toolchain:
+
+```console
+fuelup toolchain install beta-4
+```
+If the toolchain was successfully installed, you will see this output:
+
+```sh
+The Fuel toolchain is installed and up to date
+```
+
+The toolchain was installed correctly, however is not in use yet. Next, you need to configure `fuelup` to use the `beta-4` toolchain as the default.
+
+👉 Set `beta-4` as your default toolchain with the following command:
+
+```console
+fuelup default beta-4
+```
+
+You will get the following output indicating that you have successfully set `beta-4` as your default toolchain.
+
+```console
+default toolchain set to 'beta-4'
+```
+
+### Checking your current toolchain
+
+Sometimes you might end up using multiple toolchains at once. Don't worry if you get confused about which toolchain you are using, since you can check your current toolchain anytime.
+
+👉 Run the `fuelup show` command to see the toolchain and the versions of each tool you are using.
+
+```sh
+fuelup show
+```
+
+This command will give you the following output
+
+```sh
+active toolchain
+-----------------
+beta-4-x86_64-unknown-linux-gnu (default)
+ forc : 0.45.0
+ - forc-client
+ - forc-deploy : 0.45.0
+ - forc-run : 0.45.0
+ - forc-doc : 0.45.0
+ - forc-explore : 0.28.1
+ - forc-fmt : 0.45.0
+ - forc-index : 0.20.7
+ - forc-lsp : 0.45.0
+ - forc-tx : 0.45.0
+ - forc-wallet : 0.3.0
+ fuel-core : 0.20.4
+ fuel-core-keygen : Error getting version string
+ fuel-indexer : 0.20.7
+
+fuels versions
+---------------
+forc : 0.45
+forc-wallet : 0.45
+```
+
+As you can see, the beta-4 toolchain is active 🚀
+
+## What's next?
+
+Now you are ready to start building with Fuel.
+
+👉 Check out the [quickstart guide](/guides/quickstart) to deploy your first smart contract.
+
+## Beyond the basics
+
+### Custom toolchains
+
+You can create your own set of specific versions, this is known as 'custom toolchains'.
+
+> 👉 Visit the [Fuelup docs](docs/fuelup/concepts/toolchains) to learn how to set up your own custom toolchains.
+
+### Build form source
+
+You can always build the Fuel packages from source.
+
+> 👉 Visit the [Fuelup docs](docs/fuelup/install/other) to get more details about other types of installation.
+
+### Github Codespaces
+
+It's always possible to run a development environment in the browser.
+
+> 👉 Please visit our guide on [Github Codespaces](guides/installation/codespace) to use the Fuel toolchain in the browser.
\ No newline at end of file
diff --git a/docs/guides/docs/nav.json b/docs/guides/docs/nav.json
index 2ae7112e2..8cb8b58ca 100644
--- a/docs/guides/docs/nav.json
+++ b/docs/guides/docs/nav.json
@@ -1,5 +1,6 @@
{
"menu": ["Quickstart", "Running a Node", "Testnet Migration"],
+ "installation": ["Fuel Github Codespace"],
"quickstart": ["Building a Smart Contract", "Building a Frontend"],
"running_a_node": ["Running a Local Node", "Running a Beta-4 Node"],
"testnet_migration": ["Beta 4 Testnet Migration"]
diff --git a/docs/guides/docs/quickstart/building-a-smart-contract.mdx b/docs/guides/docs/quickstart/building-a-smart-contract.mdx
index 2c349ea4a..e20d728b0 100644
--- a/docs/guides/docs/quickstart/building-a-smart-contract.mdx
+++ b/docs/guides/docs/quickstart/building-a-smart-contract.mdx
@@ -1,402 +1,355 @@
----
-title: Building a Smart Contract
-category: Quickstart
-parent:
- label: Guides
- link: /guides
----
-
-# Writing A Sway Smart Contract
-
-## Installation
-
-{/* This example should include the instructions for installing Rust & Fuelup */}
-{/* installation:example:start */}
-Start by [installing the Rust toolchain](https://www.rust-lang.org/tools/install).
-
-```console
-curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-```
-
-Then, [install the Fuel toolchain](/docs/fuelup/installation).
-
-```console
-curl --proto '=https' --tlsv1.2 -sSf https://install.fuel.network/fuelup-init.sh | sh
-```
-{/* installation:example:end */}
-
-{/* This example should include the instructions for installing the latest toolchain */}
-{/* toolchain_installation:example:start */}
-Make sure you have the latest version of `fuelup` by running the following command:
-
-```console
-fuelup self update
-```
-
-```console
-Fetching binary from https://github.com/FuelLabs/fuelup/releases/download/v0.19.5/fuelup-0.19.5-aarch64-apple-darwin.tar.gz
-Downloading component fuelup without verifying checksum
-Unpacking and moving fuelup to /var/folders/tp/0l8zdx9j4s9_n609ykwxl0qw0000gn/T/.tmpiNJQHt
-Moving /var/folders/tp/0l8zdx9j4s9_n609ykwxl0qw0000gn/T/.tmpiNJQHt/fuelup to /Users/.fuelup/bin/fuelup
-```
-
-Next, install the `beta-4` toolchain with:
-
-```console
-fuelup toolchain install beta-4
-```
-
-Finally, set the `beta-4` toolchain as your default distribution with the following command:
-
-```console
-fuelup default beta-4
-```
-
-```console
-default toolchain set to 'beta-4'
-```
-
-You can check your current toolchain anytime by running `fuelup show`.
-{/* toolchain_installation:example:end */}
-
-> Having problems with this part? Post your question on our forum [https://forum.fuel.network/](https://forum.fuel.network/). To help you as efficiently as possible, include the output of this command in your post: `fuelup show.`
-
-## Your First Sway Project
-
-We'll build a simple counter contract with two functions: one to increment the counter, and one to return the value of the counter.
-
-**Start by creating a new, empty folder. We'll call it `fuel-project`.**
-
-```sh
-mkdir fuel-project
-```
-
-### Writing the Contract
-
-Move inside of your `fuel-project` folder:
-
-```sh
-cd fuel-project
-```
-
-Then create a contract project using forc:
-
-```sh
-forc new counter-contract
-```
-
-You will get this output:
-
-```sh
-To compile, use `forc build`, and to run tests use `forc test`
-----
-Read the Docs:
-- Sway Book: https://docs.fuel.network/docs/sway
-- Forc Book: https://docs.fuel.network/docs/forc
-- Rust SDK Book: https://docs.fuel.network/docs/fuels-rs
-- TypeScript SDK: https://docs.fuel.network/docs/fuels-ts
-
-Join the Community:
-- Follow us @SwayLang: https://twitter.com/SwayLang
-- Ask questions on Discourse: https://forum.fuel.network/
-
-Report Bugs:
-- Sway Issues: https://github.com/FuelLabs/sway/issues/new
-```
-
-{/* This example should include a tree for a new forc project and explain the boilerplate files */}
-{/* forc_new:example:start */}
-Here is the project that `Forc` has initialized:
-
-```console
-$ tree counter-contract
-counter-contract
-├── Forc.toml
-└── src
- └── main.sw
-```
-
-`Forc.toml` is the _manifest file_ (similar to `Cargo.toml` for Cargo or `package.json` for Node) and defines project metadata such as the project name and dependencies.
-{/* forc_new:example:end */}
-
-Open your project in a code editor and delete everything in `src/main.sw` apart from the first line.
-
-Every Sway file must start with a declaration of what type of program the file contains; here, we've declared that this file is a contract.
-
-
-
-Next, we'll define a storage value. In our case, we have a single counter that we'll call `counter` of type 64-bit unsigned integer and initialize it to 0.
-
-
-
-### ABI
-
-An ABI defines an interface for a contract. A contract must either define or import an ABI declaration. It is considered best practice to define your ABI in a separate library and import it into your contract because this allows callers of the contract to import and use the ABI in scripts to call your contract
-
-For simplicity, we will define the ABI directly in the contract file itself.
-
-
-
-### Implement ABI
-
-Below your ABI definition, you will write the implementation of the functions defined in your ABI.
-
-
-
-**Note**: `storage.counter.read()` is an implicit return and is equivalent to `return storage.counter.read();`.
-
-Here's what your code should look like so far:
-
-File: `./counter-contract/src/main.sw`
-
-
-
-### Build the Contract
-
-Navigate to your contract folder:
-
-```console
-cd counter-contract
-```
-
-```console
-changed directory into `counter-contract`
-```
-
-Then run the following command to build your contract:
-
-```console
-forc build
-```
-
-```console
- Compiled library "core".
- Compiled library "std".
- Compiled contract "counter-contract".
- Bytecode size is 232 bytes.
-```
-
-Let's have a look at the content of the `counter-contract` folder after building:
-
-```console
-$ tree .
-.
-├── Forc.lock
-├── Forc.toml
-├── out
-│ └── debug
-│ ├── counter-contract-abi.json
-│ ├── counter-contract-storage_slots.json
-│ └── counter-contract.bin
-└── src
- └── main.sw
-```
-
-We now have an `out` directory that contains our build artifacts such as the JSON representation of our ABI and the contract bytecode.
-
-## Testing your Contract
-
-We will start by adding a Rust integration test harness using a Cargo generate template. If this is your first time going through this quickstart, you'll need to install the `cargo generate` command. In the future, you can skip this step as it will already be installed.
-
-Let's start by running the installation command:
-
-```console
-cargo install cargo-generate
-```
-
-```console
- Updating crates.io index...
- installed package `cargo-generate v0.17.3`
-```
-
-> **Note**: You can learn more about cargo generate by visiting [its repository](https://github.com/cargo-generate/cargo-generate).
-
-Now, let's generate the default test harness with the following:
-
-```console
-cargo generate --init fuellabs/sway templates/sway-test-rs --name counter-contract
-```
-
-```console
-⚠️ Favorite `fuellabs/sway` not found in config, using it as a git repository: https://github.com/fuellabs/sway.git
-🔧 Destination: /home/user/path/to/counter-contract ...
-🔧 project-name: counter-contract ...
-🔧 Generating template ...
-🔧 Moving generated files into: `/home/user/path/to/counter-contract`...
-✨ Done! New project created /home/user/path/to/counter-contract
-```
-
-Let's have a look at the result:
-
-```console
-$ tree .
-.
-├── Cargo.toml
-├── Forc.lock
-├── Forc.toml
-├── out
-│ └── debug
-│ ├── counter-contract-abi.json
-│ ├── counter-contract-storage_slots.json
-│ └── counter-contract.bin
-├── src
-│ └── main.sw
-└── tests
- └── harness.rs
-```
-
-We have two new files!
-
-- The `Cargo.toml` is the manifest for our new test harness and specifies the required dependencies including `fuels` the Fuel Rust SDK.
-- The `tests/harness.rs` contains some boilerplate test code to get us started, though doesn't call any contract methods just yet.
-
-Now that we have our default test harness, let's add some useful tests to it.
-
-At the bottom of `test/harness.rs` below the `can_get_contract_id()` test, add the `test_increment` test function below to verify that the value of the counter gets incremented:
-
-
-
-Here is what your file should look like:
-
-File: `./counter-contract/tests/harness.rs`
-
-
-
-Run `cargo test` in the terminal:
-
-```console
-cargo test
-```
-
-If all goes well, the output should look as follows:
-
-```console
- ...
- running 2 tests
- test can_get_contract_id ... ok
- test test_increment ... ok
- test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.25s
-```
-
-## Deploy the Contract
-
-It's now time to deploy the contract to the testnet. We will show how to do this using `forc` from the command line, but you can also do it using the [Rust SDK](/docs/fuels-rs/deploying) or the [TypeScript SDK](/docs/fuels-ts/contracts/deploying-contracts).
-
-In order to deploy a contract, you need to have a wallet to sign the transaction and coins to pay for gas. First, we'll create a wallet.
-
-### Setup the Wallet CLI
-
-If you haven't deployed a contract before, you'll need to set up a local wallet with the forc-wallet plugin. `forc-wallet` is packaged alongside the default distributed toolchains when installed using fuelup, so you should already have this installed.
-
-You can initialize a new wallet with the command below:
-
-```console
-forc wallet new
-```
-
-After typing in a password, be sure to save the mnemonic phrase that is output.
-
-Next, create a new wallet account with:
-
-```console
-forc wallet account new
-```
-
-With this, you'll get a fuel address that looks something like this: `fuel1efz7lf36w9da9jekqzyuzqsfrqrlzwtt3j3clvemm6eru8fe9nvqj5kar8`. Save this address as you'll need it to sign transactions when we deploy the contract.
-
-If you need to list your accounts, you can run the command below:
-
-```console
-forc wallet accounts
-```
-
-### Get Testnet Coins
-
-With your account address in hand, head to the [testnet faucet](https://faucet-beta-4.fuel.network/) to get some coins sent to your wallet.
-
-### Deploy To Testnet
-
-Now that you have a wallet, you can deploy with `forc deploy` and adding the `--testnet` to target the latest network:
-
-```console
-forc deploy --testnet
-```
-
-The terminal will ask for the password of the wallet:
-
-`Please provide the password of your encrypted wallet vault at "~/.fuel/wallets/.wallet":`
-
-Once you unlocked the wallet, the terminal will show a list of the accounts of this wallet:
-
-```console
-Account 0 -- fuel18caanqmumttfnm8qp0eq7u9yluydxtqmzuaqtzdjlsww5t2jmg9skutn8n:
- Asset ID Amount
- 0000000000000000000000000000000000000000000000000000000000000000 499999940
-```
-
-Just below the list, you'll see this prompt:
-
-`Please provide the index of account to use for signing:`
-
-Then you'll enter the number of the account of preference and press `Y` when prompted to accept the transaction.
-
-Finally, you will get back the network endpoint where the contract was deployed, a `Contract ID` and the block where the transaction was signed.
-Save the `Contract ID`, as you'll need this later to connect the frontend.
-With this ID, you can also head to the [block explorer](https://fuellabs.github.io/block-explorer-v2/) to confirm the contract was deployed.
-
-```console
-Contract deploy-to-beta-4 Deployed!
-
-Network: https://beta-4.fuel.network
-Contract ID: 0x8342d413de2a678245d9ee39f020795800c7e6a4ac5ff7daae275f533dc05e08
-Deployed in block 0x4ea52b6652836c499e44b7e42f7c22d1ed1f03cf90a1d94cd0113b9023dfa636
-```
-
-
-![block explorer](/images/block-explorer.png)
-
-
-### Congrats, you have completed your first smart contract on Fuel ⛽
-
-[Here is the repo for this project](https://github.com/FuelLabs/quickstart). If you run into any problems, a good first step is to compare your code to this repo and resolve any differences.
-
-Tweet us [@fuel_network](https://twitter.com/fuel_network) letting us know you just built a dapp on Fuel, you might get invited to a private group of builders, be invited to the next Fuel dinner, get alpha on the project, or something 👀.
-
-## Need Help?
-
-Get help from the team by posting your question in the [Fuel Forum](https://forum.fuel.network/).
+---
+title: Building a Smart Contract
+category: Quickstart
+parent:
+ label: Guides
+ link: /guides
+---
+
+# Writing A Sway Smart Contract
+
+## Installation
+
+Please visit the [installation guide](guides/installation) to install the Fuel toolchain binaries and prerequisites.
+
+> Having problems with this part? Post your question on our forum [https://forum.fuel.network/](https://forum.fuel.network/). To help you as efficiently as possible, include the output of this command in your post: `fuelup show.`
+
+## Your First Sway Project
+
+We'll build a simple counter contract with two functions: one to increment the counter, and one to return the value of the counter.
+
+**Start by creating a new, empty folder. We'll call it `fuel-project`.**
+
+```sh
+mkdir fuel-project
+```
+
+### Writing the Contract
+
+Move inside of your `fuel-project` folder:
+
+```sh
+cd fuel-project
+```
+
+Then create a contract project using `forc`:
+
+```sh
+forc new counter-contract
+```
+
+You will get this output:
+
+```sh
+To compile, use `forc build`, and to run tests use `forc test`
+----
+Read the Docs:
+- Sway Book: https://docs.fuel.network/docs/sway
+- Forc Book: https://docs.fuel.network/docs/forc
+- Rust SDK Book: https://docs.fuel.network/docs/fuels-rs
+- TypeScript SDK: https://docs.fuel.network/docs/fuels-ts
+
+Join the Community:
+- Follow us @SwayLang: https://twitter.com/SwayLang
+- Ask questions on Discourse: https://forum.fuel.network/
+
+Report Bugs:
+- Sway Issues: https://github.com/FuelLabs/sway/issues/new
+```
+
+{/* This example should include a tree for a new `forc` project and explain the boilerplate files */}
+{/* forc_new:example:start */}
+Here is the project that `forc` has initialized:
+
+```console
+$ tree counter-contract
+counter-contract
+├── Forc.toml
+└── src
+ └── main.sw
+```
+
+`forc.toml` is the _manifest file_ (similar to `Cargo.toml` for Cargo or `package.json` for Node) and defines project metadata such as the project name and dependencies.
+{/* forc_new:example:end */}
+
+Open your project in a code editor and delete everything in `src/main.sw` apart from the first line.
+
+Every Sway file must start with a declaration of what type of program the file contains; here, we've declared that this file is a contract.
+
+
+
+Next, we'll define a storage value. In our case, we have a single counter that we'll call `counter` of type 64-bit unsigned integer and initialize it to 0.
+
+
+
+### ABI
+
+An ABI defines an interface for a contract. A contract must either define or import an ABI declaration. It is considered best practice to define your ABI in a separate library and import it into your contract because this allows callers of the contract to import and use the ABI in scripts to call your contract
+
+For simplicity, we will define the ABI directly in the contract file itself.
+
+
+
+### Implement ABI
+
+Below your ABI definition, you will write the implementation of the functions defined in your ABI.
+
+
+
+**Note**: `storage.counter.read()` is an implicit return and is equivalent to `return storage.counter.read();`.
+
+Here's what your code should look like so far:
+
+File: `./counter-contract/src/main.sw`
+
+
+
+### Build the Contract
+
+Navigate to your contract folder:
+
+```console
+cd counter-contract
+```
+
+```console
+changed directory into `counter-contract`
+```
+
+Then run the following command to build your contract:
+
+```console
+forc build
+```
+
+```console
+ Compiled library "core".
+ Compiled library "std".
+ Compiled contract "counter-contract".
+ Bytecode size is 232 bytes.
+```
+
+Let's have a look at the content of the `counter-contract` folder after building:
+
+```console
+$ tree .
+.
+├── Forc.lock
+├── Forc.toml
+├── out
+│ └── debug
+│ ├── counter-contract-abi.json
+│ ├── counter-contract-storage_slots.json
+│ └── counter-contract.bin
+└── src
+ └── main.sw
+```
+
+We now have an `out` directory that contains our build artifacts such as the JSON representation of our ABI and the contract bytecode.
+
+## Testing your Contract
+
+We will start by adding a Rust integration test harness using a Cargo generate template. If this is your first time going through this quickstart, you'll need to install the `cargo generate` command. In the future, you can skip this step as it will already be installed.
+
+Let's start by running the installation command:
+
+```console
+cargo install cargo-generate
+```
+
+```console
+ Updating crates.io index...
+ installed package `cargo-generate v0.17.3`
+```
+
+> **Note**: You can learn more about cargo generate by visiting [its repository](https://github.com/cargo-generate/cargo-generate).
+
+Now, let's generate the default test harness with the following:
+
+```console
+cargo generate --init fuellabs/sway templates/sway-test-rs --name counter-contract
+```
+
+```console
+⚠️ Favorite `fuellabs/sway` not found in config, using it as a git repository: https://github.com/fuellabs/sway.git
+🔧 Destination: /home/user/path/to/counter-contract ...
+🔧 project-name: counter-contract ...
+🔧 Generating template ...
+🔧 Moving generated files into: `/home/user/path/to/counter-contract`...
+✨ Done! New project created /home/user/path/to/counter-contract
+```
+
+Let's have a look at the result:
+
+```console
+$ tree .
+.
+├── Cargo.toml
+├── Forc.lock
+├── Forc.toml
+├── out
+│ └── debug
+│ ├── counter-contract-abi.json
+│ ├── counter-contract-storage_slots.json
+│ └── counter-contract.bin
+├── src
+│ └── main.sw
+└── tests
+ └── harness.rs
+```
+
+We have two new files!
+
+- The `Cargo.toml` is the manifest for our new test harness and specifies the required dependencies including `fuels` the Fuel Rust SDK.
+- The `tests/harness.rs` contains some boilerplate test code to get us started, though doesn't call any contract methods just yet.
+
+Now that we have our default test harness, let's add some useful tests to it.
+
+At the bottom of `test/harness.rs` below the `can_get_contract_id()` test, add the `test_increment` test function below to verify that the value of the counter gets incremented:
+
+
+
+Here is what your file should look like:
+
+File: `./counter-contract/tests/harness.rs`
+
+
+
+Run `cargo test` in the terminal:
+
+```console
+cargo test
+```
+
+If all goes well, the output should look as follows:
+
+```console
+ ...
+ running 2 tests
+ test can_get_contract_id ... ok
+ test test_increment ... ok
+ test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.25s
+```
+
+## Deploy the Contract
+
+It's now time to deploy the contract to the testnet. We will show how to do this using `forc` from the command line, but you can also do it using the [Rust SDK](/docs/fuels-rs/deploying) or the [TypeScript SDK](/docs/fuels-ts/contracts/deploying-contracts).
+
+In order to deploy a contract, you need to have a wallet to sign the transaction and coins to pay for gas. First, we'll create a wallet.
+
+### Setup the Wallet CLI
+
+If you haven't deployed a contract before, you'll need to set up a local wallet with the forc-wallet plugin. `forc-wallet` is packaged alongside the default distributed toolchains when installed using fuelup, so you should already have this installed.
+
+You can initialize a new wallet with the command below:
+
+```console
+forc wallet new
+```
+
+After typing in a password, be sure to save the mnemonic phrase that is output.
+
+Next, create a new wallet account with:
+
+```console
+forc wallet account new
+```
+
+With this, you'll get a fuel address that looks something like this: `fuel1efz7lf36w9da9jekqzyuzqsfrqrlzwtt3j3clvemm6eru8fe9nvqj5kar8`. Save this address as you'll need it to sign transactions when we deploy the contract.
+
+If you need to list your accounts, you can run the command below:
+
+```console
+forc wallet accounts
+```
+
+### Get Testnet Coins
+
+With your account address in hand, head to the [testnet faucet](https://faucet-beta-4.fuel.network/) to get some coins sent to your wallet.
+
+### Deploy To Testnet
+
+Now that you have a wallet, you can deploy with `forc deploy` and adding the `--testnet` to target the latest network:
+
+```console
+forc deploy --testnet
+```
+
+The terminal will ask for the password of the wallet:
+
+`Please provide the password of your encrypted wallet vault at "~/.fuel/wallets/.wallet":`
+
+Once you unlocked the wallet, the terminal will show a list of the accounts of this wallet:
+
+```console
+Account 0 -- fuel18caanqmumttfnm8qp0eq7u9yluydxtqmzuaqtzdjlsww5t2jmg9skutn8n:
+ Asset ID Amount
+ 0000000000000000000000000000000000000000000000000000000000000000 499999940
+```
+
+Just below the list, you'll see this prompt:
+
+`Please provide the index of account to use for signing:`
+
+Then you'll enter the number of the account of preference and press `Y` when prompted to accept the transaction.
+
+Finally, you will get back the network endpoint where the contract was deployed, a `Contract ID` and the block where the transaction was signed.
+Save the `Contract ID`, as you'll need this later to connect the frontend.
+With this ID, you can also head to the [block explorer](https://fuellabs.github.io/block-explorer-v2/) to confirm the contract was deployed.
+
+```console
+Contract deploy-to-beta-4 Deployed!
+
+Network: https://beta-4.fuel.network
+Contract ID: 0x8342d413de2a678245d9ee39f020795800c7e6a4ac5ff7daae275f533dc05e08
+Deployed in block 0x4ea52b6652836c499e44b7e42f7c22d1ed1f03cf90a1d94cd0113b9023dfa636
+```
+
+
+![block explorer](/images/block-explorer.png)
+
+
+### Congrats, you have completed your first smart contract on Fuel ⛽
+
+[Here is the repo for this project](https://github.com/FuelLabs/quickstart). If you run into any problems, a good first step is to compare your code to this repo and resolve any differences.
+
+Tweet us [@fuel_network](https://twitter.com/fuel_network) letting us know you just built a dapp on Fuel, you might get invited to a private group of builders, be invited to the next Fuel dinner, get alpha on the project, or something 👀.
+
+## Need Help?
+
+Get help from the team by posting your question in the [Fuel Forum](https://forum.fuel.network/).
diff --git a/package.json b/package.json
index 0e3a603ce..3bf81682a 100644
--- a/package.json
+++ b/package.json
@@ -100,7 +100,9 @@
"semver@<7.5.2": ">=7.5.2",
"word-wrap": "npm:@aashutoshrathi/word-wrap",
"@adobe/css-tools@<4.3.1": ">=4.3.1",
- "graphql@>=16.3.0 <16.8.1": ">=16.8.1"
+ "graphql@>=16.3.0 <16.8.1": ">=16.8.1",
+ "postcss@<8.4.31": ">=8.4.31",
+ "zod@<=3.22.2": ">=3.22.3"
}
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 97c2fce99..5c4937926 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -9,6 +9,8 @@ overrides:
word-wrap: npm:@aashutoshrathi/word-wrap
'@adobe/css-tools@<4.3.1': '>=4.3.1'
graphql@>=16.3.0 <16.8.1: '>=16.8.1'
+ postcss@<8.4.31: '>=8.4.31'
+ zod@<=3.22.2: '>=3.22.3'
dependencies:
'@docsearch/css':
@@ -445,7 +447,7 @@ packages:
ts-pattern: 4.3.0
unified: 10.1.2
yaml: 2.3.2
- zod: 3.22.2
+ zod: 3.22.3
transitivePeerDependencies:
- '@effect-ts/otel-node'
- esbuild
@@ -8074,12 +8076,12 @@ packages:
'@swc/helpers': 0.5.1
busboy: 1.6.0
caniuse-lite: 1.0.30001525
- postcss: 8.4.14
+ postcss: 8.4.31
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
styled-jsx: 5.1.1(react@18.2.0)
watchpack: 2.4.0
- zod: 3.21.4
+ zod: 3.22.3
optionalDependencies:
'@next/swc-darwin-arm64': 13.4.19
'@next/swc-darwin-x64': 13.4.19
@@ -8488,8 +8490,8 @@ packages:
- supports-color
dev: false
- /postcss@8.4.14:
- resolution: {integrity: sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==}
+ /postcss@8.4.31:
+ resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.6
@@ -10111,12 +10113,8 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
- /zod@3.21.4:
- resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==}
- dev: false
-
- /zod@3.22.2:
- resolution: {integrity: sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==}
+ /zod@3.22.3:
+ resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==}
dev: false
/zustand@4.4.1(@types/react@18.2.21)(react@18.2.0):
diff --git a/public/images/create-codespace.gif b/public/images/create-codespace.gif
new file mode 100644
index 000000000..9b3beb0c4
Binary files /dev/null and b/public/images/create-codespace.gif differ
diff --git a/public/images/dev-container.gif b/public/images/dev-container.gif
new file mode 100644
index 000000000..376347986
Binary files /dev/null and b/public/images/dev-container.gif differ
diff --git a/scripts/generate-links.mjs b/scripts/generate-links.mjs
index fbb2b2bdb..e5ef6a52e 100644
--- a/scripts/generate-links.mjs
+++ b/scripts/generate-links.mjs
@@ -13,6 +13,7 @@ const indexerSummaryPath = join(
'./fuel-indexer/docs/src/SUMMARY.md'
);
const specsSummaryPath = join(DOCS_DIRECTORY, './fuel-specs/src/SUMMARY.md');
+// const nixSummaryPath = join(DOCS_DIRECTORY, './fuel-nix/book/src/SUMMARY.md');
const graphqlOrderPath = join(
DOCS_DIRECTORY,
@@ -42,6 +43,8 @@ const specsSummaryFile = fs.readFileSync(specsSummaryPath, 'utf8');
const graphqlOrderFile = JSON.parse(fs.readFileSync(graphqlOrderPath, 'utf8'));
const guidesOrderFile = JSON.parse(fs.readFileSync(guidesOrderPath, 'utf8'));
const walletOrderFile = JSON.parse(fs.readFileSync(walletOrderPath, 'utf8'));
+// const nixSummaryFile = fs.readFileSync(nixSummaryPath, 'utf8');
+
// const aboutFuelOrderFile = JSON.parse(
// fs.readFileSync(aboutFuelOrderPath, 'utf8')
// );
@@ -247,6 +250,9 @@ async function getOrders() {
orders.indexer = processSummary(indexerSummaryFile.split(EOL), 'indexer');
// SPECS ORDER
orders.specs = processSummary(specsSummaryFile.split(EOL), 'specs');
+
+ // orders.nix = processSummary(nixSummaryFile.split(EOL), 'specs');
+
// GRAPHQL ORDER
orders.graphql = graphqlOrderFile;
@@ -487,6 +493,15 @@ async function getDocs(key, order) {
'!**/SUMMARY.md',
];
break;
+ // case 'nix':
+ // paths = [
+ // // SPECS DOCS
+ // './fuel-nix/book/src/*.md',
+ // './fuel-nix/book/src/**/*.md',
+ // // IGNORE ALL SUMMARY PAGES
+ // '!**/SUMMARY.md',
+ // ];
+ // break;
// case 'about-fuel':
// paths = [
// // ABOUT FUEL DOCS
diff --git a/src/config/constants.ts b/src/config/constants.ts
index 8c15b5d96..9a6d815af 100644
--- a/src/config/constants.ts
+++ b/src/config/constants.ts
@@ -15,6 +15,7 @@ export type Tabs =
| 'indexer'
| 'specs'
// | 'about-fuel'
+ // | 'nix'
| 'forc';
export type LinkType = 'menu' | 'internal-link' | 'external-link' | 'category';
@@ -97,6 +98,12 @@ export const NAVIGATION: LinkObject[] = [
link: '/docs/indexer/',
slug: 'indexer',
},
+ // {
+ // name: 'Fuel Nix',
+ // type: 'internal-link',
+ // link: '/docs/nix/',
+ // slug: 'nix',
+ // },
],
},
{