Skip to content

Commit 981b992

Browse files
authored
docs: improving getting started docs for mainnet (#3500)
1 parent ca123e6 commit 981b992

23 files changed

+285
-209
lines changed

.changeset/brave-lies-relax.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fuels": patch
3+
---
4+
5+
docs: improving getting started docs for `mainnet`

README.md

+77-62
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,107 @@
1-
<picture>
2-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/FuelLabs/fuels-ts/master/apps/docs/src/public/fuels-ts-logo-dark.png">
3-
<img alt="Fuels-ts SDK logo" width="400px" src="https://raw.githubusercontent.com/FuelLabs/fuels-ts/master/apps/docs/src/public/fuels-ts-logo-light.png">
4-
</picture>
1+
# fuels-ts
52

6-
**fuels-ts** is a library for interacting with **Fuel v2**.
3+
Typescript SDK for Fuel.
74

85
[![test](https://github.com/FuelLabs/fuels-ts/actions/workflows/test.yaml/badge.svg)](https://github.com/FuelLabs/fuels-ts/actions/workflows/test.yaml)
9-
[![npm](https://img.shields.io/npm/v/fuels)](https://www.npmjs.com/package/fuels)
106
[![docs](https://img.shields.io/badge/docs-fuels.ts-brightgreen.svg?style=flat)](https://docs.fuel.network/docs/fuels-ts/)
7+
[![npm](https://img.shields.io/npm/v/fuels)](https://www.npmjs.com/package/fuels)
118
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)
129

13-
# Resources
14-
15-
The [documentation](https://docs.fuel.network/docs/fuels-ts/) site is your main stop for resources.
10+
# Install ([docs](https://docs.fuel.network/docs/fuels-ts/getting-started/installation))
1611

17-
- [Quickstart](https://docs.fuel.network/docs/intro/quickstart-contract/)
18-
- [Documentation](https://docs.fuel.network/docs/fuels-ts/)
19-
- [Wallets](https://docs.fuel.network/docs/fuels-ts/wallets/)
20-
- [Contracts](https://docs.fuel.network/docs/fuels-ts/contracts/)
21-
- [Scripts](https://docs.fuel.network/docs/fuels-ts/scripts/)
22-
- [Predicates](https://docs.fuel.network/docs/fuels-ts/predicates/)
23-
- [ABI Typegen](https://docs.fuel.network/docs/fuels-ts/fuels-cli/abi-typegen/)
24-
- [Contributing](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md)
25-
- [The Fuel Forum](https://forum.fuel.network/)
26-
- [The Fuel Ecosystem](#the-fuel-ecosystem)
27-
28-
# Install
29-
30-
```sh
12+
```console
3113
npm install fuels --save
3214
```
3315

34-
> If you are a Windows user, you will need to be running Windows Subsystem for Linux (WSL) to install and use the Fuel toolchain, including the TypeScript SDK. We don't support Windows natively at this time.
16+
# Connect ([docs](https://docs.fuel.network/docs/fuels-ts/getting-started/connecting-to-the-network/))
3517

36-
# Import
37-
38-
Simple example usages.
18+
| Network | URL |
19+
| --------- | --------------------------------------------------------------------------------------------------------------- |
20+
| Mainnet | `https://mainnet.fuel.network/v1/graphql` |
21+
| Testnet | `https://testnet.fuel.network/v1/graphql` |
22+
| Localhost | [Running a local Fuel node](https://docs.fuel.network/docs/fuels-ts/getting-started/running-a-local-fuel-node/) |
3923

4024
```ts
41-
import { Wallet } from "fuels";
25+
import { Provider } from 'fuels';
4226

43-
// Random Wallet
44-
console.log(Wallet.generate());
27+
const NETWORK_URL = 'https://mainnet.fuel.network/v1/graphql';
4528

46-
// Using privateKey Wallet
47-
console.log(new Wallet("0x0000...0000"));
48-
```
29+
const provider = await Provider.create(NETWORK_URL);
4930

50-
# CLI
31+
const chainId = provider.getChainId();
32+
const gasConfig = provider.getGasConfig();
33+
const baseAssetId = provider.getBaseAssetId();
5134

52-
Fuels include some utility commands via built-in CLI tool.
35+
console.log({ chainId, gasConfig, baseAssetId });
36+
```
5337

54-
Check the [docs](https://docs.fuel.network/docs/fuels-ts/) for more info.
38+
# Create a new dApp ([docs](https://docs.fuel.network/docs/fuels-ts/creating-a-fuel-dapp/))
5539

5640
```console
57-
$ npm add fuels
58-
$ npx fuels --help
59-
Usage: fuels [options] [command]
41+
$ npm create fuels
42+
43+
◇ What is the name of your project? #
44+
│ my-fuel-project
45+
46+
47+
⚡️ Success! Created a fullstack Fuel dapp at: my-fuel-project.
48+
```
6049

61-
Options:
62-
-D, --debug Enables verbose logging (default: false)
63-
-S, --silent Omit output messages (default: false)
64-
-v, --version Output the version number
65-
-h, --help Display help
50+
# Enjoy the `fuels` CLI ([docs](https://docs.fuel.network/docs/fuels-ts/fuels-cli/))
51+
52+
```console
53+
$ npm install fuels --save
54+
$ npm fuels --help
6655

6756
Commands:
68-
init [options] Create a sample `fuel.config.ts` file
69-
node [options] Start a Fuel node
70-
dev [options] Start a Fuel node and run build + deploy on every file change
71-
build [options] Build Sway programs and generate Typescript for them
72-
deploy [options] Deploy contracts to the Fuel network
73-
typegen [options] Generate Typescript from Sway ABI JSON files
74-
versions Check for version incompatibilities
75-
help [command] Display help for command
57+
init [options] Create a sample `fuel.config.ts` file
58+
build [options] Build Sway programs and generate Typescript for them
59+
deploy [options] Deploy contracts to the Fuel network
60+
dev [options] Start a Fuel node with hot-reload capabilities
61+
node [options] Start a Fuel node using project configs
62+
typegen [options] Generate Typescript from Sway ABI JSON files
63+
versions [options] Check for version incompatibilities
64+
help [command] Display help for command
7665
```
7766

78-
# The Fuel Ecosystem
67+
In-depth docs:
68+
- [`fuels init`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-init) — Creates a new `fuels.config.ts` file
69+
- [`fuels build`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-build) — Build `forc` workspace and generate Typescript types for everything
70+
- [`fuels deploy`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-deploy) — Deploy workspace contracts and save their IDs to JSON file
71+
- [`fuels dev`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-dev) — Start a Fuel node with hot-reload capabilities
72+
73+
74+
# Official Docs
75+
76+
- Install The Fuel Toolchain — https://docs.fuel.network/guides/installation/
77+
---
78+
- Typescript SDK — https://docs.fuel.network/docs/fuels-ts
79+
- Fuel Wallet SDK — https://docs.fuel.network/docs/wallet
80+
- Rust SDK — https://docs.fuel.network/docs/fuels-rs
81+
- GraphQL Playground — https://docs.fuel.network/docs/graphql
82+
---
83+
- Forc — https://docs.fuel.network/docs/forc
84+
- Sway — https://docs.fuel.network/docs/sway
85+
- Fuel Core — https://github.com/FuelLabs/fuel-core
86+
- Fuel VM — https://docs.fuel.network/docs/specs/fuel-vm
87+
- Fuel Specs — https://docs.fuel.network/docs/specs
88+
89+
# Apps & Ecosystem
90+
91+
- Fuel Bridge — https://app.fuel.network/bridge
92+
- Block Explorer — https://app.fuel.network
93+
- Ecosystem Apps — https://app.fuel.network/ecosystem
94+
95+
# Get in Touch
96+
97+
- `Forum`https://forum.fuel.network
98+
- `Discord`https://discord.gg/xfpK4Pe
99+
100+
101+
# Contribute
79102

80-
Learn more about the Fuel Ecosystem.
103+
- [./CONTRIBUTING.md](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md)
81104

82-
- [🌴 Sway](https://docs.fuel.network/docs/sway/) — The new language, empowering everyone to build reliable and efficient smart contracts
83-
- [🧰 Forc](https://docs.fuel.network/docs/forc/) — The Fuel toolbox: _Build, deploy and manage your sway projects_
84-
- [⚙️ Fuel Core](https://github.com/FuelLabs/fuel-core) — The new FuelVM, a blazingly fast blockchain VM
85-
- [🔗 Fuel Specs](https://github.com/FuelLabs/fuel-specs) — The Fuel protocol specifications
86-
- [💼 Fuels Wallet](https://github.com/FuelLabs/fuels-wallet) — The Official Fuels Wallet
87-
- [🦀 Rust SDK](https://github.com/FuelLabs/fuels-rs) — A robust SDK in rust
88-
- [⚡ Fuel Network](https://fuel.network/) — The project
89-
- [📚 The Fuel Forum](https://forum.fuel.network/) — Ask questions, get updates, and contribute to a modular future
90105

91106
# License
92107

apps/docs/.vitepress/config.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,24 @@ export default defineConfig({
5151
link: '/guide/getting-started/installation',
5252
},
5353
{
54-
text: 'Usage',
55-
link: '/guide/getting-started/usage',
54+
text: 'Connecting to the Network',
55+
link: '/guide/getting-started/connecting-to-the-network',
5656
},
5757
{
58-
text: 'Connecting to Testnet',
59-
link: '/guide/getting-started/connecting-to-testnet',
58+
text: 'Running a local Fuel node',
59+
link: '/guide/getting-started/running-a-local-fuel-node',
6060
},
6161
{
62-
text: 'Connecting to a Local Node',
63-
link: '/guide/getting-started/connecting-to-a-local-node',
62+
text: 'React Example',
63+
link: '/guide/getting-started/react-example',
6464
},
6565
{
66-
text: 'Further Resources',
67-
link: '/guide/getting-started/further-resources',
66+
text: 'CDN Usage',
67+
link: '/guide/getting-started/cdn-usage',
68+
},
69+
{
70+
text: 'Next Steps',
71+
link: '/guide/getting-started/next-steps',
6872
},
6973
],
7074
},

apps/docs/src/guide/fuels-cli/commands.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ The `fuels dev` command does three things:
143143
npx fuels@{{fuels}} node
144144
```
145145

146-
The `fuels node` command starts a short-lived `fuel-core` node ([docs](./config-file.md#autostartfuelcore)).
146+
Starts a short-lived `fuel-core` node and requires a `fuels.config.ts` config file.
147+
148+
Generate one with [`fuels init`](#fuels-init):
149+
150+
<<< @/../../demo-fuels/fuels.config.minimal.ts#config{ts:line-numbers}
147151

148152
## `fuels typegen`
149153

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script setup>
2+
import { data } from '../../versions.data'
3+
const { fuels } = data
4+
</script>
5+
6+
# CDN Usage (browser only)
7+
8+
```html-vue
9+
<script type="module">
10+
import {
11+
Wallet,
12+
Provider,
13+
} from "https://cdnjs.cloudflare.com/ajax/libs/fuels/{{fuels}}/browser.mjs";
14+
15+
const main = async () => {
16+
const provider = await Provider.create(
17+
"https://mainnet.fuel.network/v1/graphql",
18+
);
19+
const { name } = provider.getChain();
20+
console.log(name);
21+
};
22+
23+
main();
24+
</script>
25+
```
26+
27+
# More
28+
29+
- [React Example](./react-example.md)

apps/docs/src/guide/getting-started/connecting-to-a-local-node.md

-10
This file was deleted.

apps/docs/src/guide/getting-started/connecting-to-testnet.md

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Connecting to the Network
2+
3+
After [installing](./installation.md) the `fuels` package, it's easy to connect to the Network:
4+
5+
<<< @./snippets/connecting-to-the-network.ts#main{ts:line-numbers}
6+
7+
# RPC URLs
8+
9+
These are our official RPC URLs:
10+
11+
| Network | URL |
12+
| --------- | ----------------------------------------------------------- |
13+
| Mainnet | `https://testnet.fuel.network/v1/graphql` |
14+
| Testnet | `https://mainnet.fuel.network/v1/graphql` |
15+
| Localhost | [Running a local Fuel node](./running-a-local-fuel-node.md) |
16+
17+
# Resources
18+
19+
Access all our apps directly:
20+
21+
| | Mainnet | Testnet |
22+
| -------- | ------------------------------------------ | ------------------------------------------ |
23+
| Faucet || https://faucet-testnet.fuel.network/ |
24+
| Explorer | https://app.fuel.network | https://app-testnet.fuel.network |
25+
| Bridge | https://app.fuel.network/bridge | https://app-testnet.fuel.network/bridge |
26+
| GraphQL | https://mainnet.fuel.network/v1/playground | https://testnet.fuel.network/v1/playground |

apps/docs/src/guide/getting-started/further-resources.md

-11
This file was deleted.
+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
# Getting Started
22

3-
This guide will walk you through the process of setting up and using the Fuels-ts library in your front-end project.
3+
Welcome to `fuels` Typescript SDK!
4+
5+
We prepared some guides to walk you through your first steps:
6+
7+
1. [Installation](./installation.md)
8+
1. [Connecting to the Network](./connecting-to-the-network.md)
9+
1. [Running a local Fuel node](./running-a-local-fuel-node.md)
10+
1. [React Example](./react-example.md)
11+
1. [CDN Usage](./cdn-usage.md)
12+
1. [Next Steps](./next-steps.md)

apps/docs/src/guide/getting-started/installation.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@
55

66
# Installation
77

8-
We expect you to install the [Fuel Toolchain](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/#the-fuel-toolchain) before using this library. Follow [this guide](https://docs.fuel.network/guides/installation/) to get this installed.
8+
You must install the [Fuel Toolchain](https://docs.fuel.network/guides/installation/) before using this library.
99

10-
The next step is to add the `fuels` dependency to your project. You can do this using the following command:
10+
Then add the `fuels` dependency to your project:
1111

1212
::: code-group
1313

14-
```sh-vue [npm]
15-
npm install fuels@{{fuels}} --save
14+
```sh-vue [bun]
15+
bun add fuels@{{fuels}}
1616
```
1717

1818
```sh-vue [pnpm]
1919
pnpm add fuels@{{fuels}}
2020
```
2121

22-
```sh-vue [bun]
23-
bun add fuels@{{fuels}}
22+
```sh-vue [npm]
23+
npm install fuels@{{fuels}} --save
2424
```
2525

2626
:::
2727

28-
**Note**: Use version `{{fuels}}` to ensure compatibility with `testnet` network—check the [docs](https://docs.fuel.network/guides/installation/#using-the-latest-toolchain).
28+
Now you are ready to:
29+
30+
- [Connect to the Network](./connecting-to-the-network.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Done!
2+
3+
Wait no more, let's build your first Fuel dApp!
4+
5+
- [Creating a Fuel dApp](../creating-a-fuel-dapp/)
6+
7+
## Further Resources
8+
9+
For a more in-depth, step-by-step guide on working with the wider Fuel ecosystem, check out the [Developer Quickstart](https://docs.fuel.network/guides/quickstart/), which uses a more procedural and detailed approach:
10+
11+
1. Installing all tools needed to develop with the Fuel ecosystem
12+
1. Writing your first Sway Project
13+
1. Deploying your contract
14+
1. Building a simple front-end dApp to interact with your deployed contract

0 commit comments

Comments
 (0)