Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improving getting started docs for mainnet #3500

Merged
merged 41 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
44b6c75
Revamping getting started docs
arboleya Dec 24, 2024
fbf6e02
Fixing outdated URLs
arboleya Dec 24, 2024
589364b
Fixing filename
arboleya Dec 24, 2024
828ff59
Renaming file
arboleya Dec 24, 2024
0648a62
Fixing more filenames
arboleya Dec 24, 2024
fbcae14
Renaming more files, adjusting texts
arboleya Dec 24, 2024
71c77b9
Using relative links
arboleya Dec 24, 2024
954a7e9
What a mess
arboleya Dec 24, 2024
2c59a56
Final touches and crosslinks
arboleya Dec 24, 2024
12e5fc4
Update apps/docs/src/guide/getting-started/cdn-usage.md
arboleya Dec 30, 2024
b411514
Adding TODO with docs
arboleya Dec 30, 2024
dd5e55a
Update apps/docs/src/guide/getting-started/index.md
arboleya Dec 30, 2024
b4a3327
Adjust text
arboleya Dec 31, 2024
894d803
Merge branch 'master' into aa/docs/connect-to-mainnet
arboleya Dec 31, 2024
bc3ccbf
Update apps/docs/src/guide/getting-started/next-steps.md
arboleya Dec 31, 2024
4da22cb
Breaking section apart
arboleya Dec 31, 2024
2cc989b
Lintfix
arboleya Jan 1, 2025
59ad1ca
Adjusting command descriptions
arboleya Jan 1, 2025
5ccc023
Revamping README
arboleya Jan 1, 2025
b429822
Adding changeset
arboleya Jan 1, 2025
bb3986a
Fixing README links
arboleya Jan 1, 2025
3514761
Fixing another link
arboleya Jan 1, 2025
c78a525
Temporarily ignoring new pages
arboleya Jan 1, 2025
2c98d3f
Touchups
arboleya Jan 1, 2025
08a29c8
Fixing more URLs
arboleya Jan 1, 2025
be38612
Update README.md
arboleya Jan 1, 2025
e07491b
Simplifying and standardizing snippets
arboleya Jan 1, 2025
8f55a71
Nit
arboleya Jan 1, 2025
d9f8842
Nit II
arboleya Jan 1, 2025
18e0d17
Adjusting snippets again
arboleya Jan 1, 2025
1288845
Touchups
arboleya Jan 1, 2025
9339ec0
Touchups+
arboleya Jan 1, 2025
51f56f3
Update README.md
arboleya Jan 2, 2025
9ddf82e
Improving `fuels node` docs
arboleya Jan 2, 2025
f2786d3
Simplifying docs
arboleya Jan 2, 2025
5ae7d8c
Oops
arboleya Jan 2, 2025
eacb8f8
Merge branch 'master' into aa/docs/connect-to-mainnet
arboleya Jan 2, 2025
e654ea2
Update apps/docs/src/guide/fuels-cli/commands.md
arboleya Jan 2, 2025
83efe57
Update README.md
arboleya Jan 2, 2025
a4d01d4
Update README.md
arboleya Jan 2, 2025
29718c4
Merge branch 'master' into aa/docs/connect-to-mainnet
arboleya Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions apps/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ export default defineConfig({
link: '/guide/getting-started/installation',
},
{
text: 'Usage',
link: '/guide/getting-started/usage',
text: 'Connecting to the Network',
link: '/guide/getting-started/connecting-to-the-network',
},
{
text: 'Connecting to Testnet',
link: '/guide/getting-started/connecting-to-testnet',
text: 'Running a local Fuel node',
link: '/guide/getting-started/running-a-local-fuel-node',
},
{
text: 'Connecting to a Local Node',
link: '/guide/getting-started/connecting-to-a-local-node',
text: 'React Example',
link: '/guide/getting-started/react-example',
},
{
text: 'Further Resources',
link: '/guide/getting-started/further-resources',
text: 'CDN Usage',
link: '/guide/getting-started/cdn-usage',
},
{
text: 'Next Steps',
link: '/guide/getting-started/next-steps',
},
],
},
Expand Down
29 changes: 29 additions & 0 deletions apps/docs/src/guide/getting-started/cdn-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup>
import { data } from '../../versions.data'
const { fuels } = data
</script>

# CDN Usage (browser only)

```html-vue
<script type="module">
import {
Wallet,
Provider,
} from "https://cdnjs.cloudflare.com/ajax/libs/fuels/{{fuels}}/browser.mjs";

const main = async () => {
const provider = await Provider.create(
"https://mainnet.fuel.network/v1/graphql",
);
const { name } = provider.getChain();
console.log(name);
};

main();
</script>
```

# More

- [React Example](./react-example.md)

This file was deleted.

22 changes: 0 additions & 22 deletions apps/docs/src/guide/getting-started/connecting-to-testnet.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Connecting to the Network

After [installing](./installation.md) the `fuels` package, it's easy to connect to the Network:

<<< @./snippets/connecting-to-the-network.ts#main{ts:line-numbers}

# RPC URLs

These are our official RPC URLs:

| Network | URL |
| --------- | ----------------------------------------------------------- |
| Mainnet | `https://testnet.fuel.network/v1/graphql` |
| Testnet | `https://mainnet.fuel.network/v1/graphql` |
| Localhost | [Running a local Fuel node](./running-a-local-fuel-node.md) |

# Resources

Access all our apps directly:

| | Mainnet | Testnet |
| -------- | ------------------------------------------ | ------------------------------------------ |
| Faucet || https://faucet-testnet.fuel.network/ |
| Explorer | https://app.fuel.network | https://app-testnet.fuel.network |
| Bridge | https://app.fuel.network/bridge | https://app-testnet.fuel.network/bridge |
| GraphQL | https://mainnet.fuel.network/v1/playground | https://testnet.fuel.network/v1/playground |
11 changes: 0 additions & 11 deletions apps/docs/src/guide/getting-started/further-resources.md

This file was deleted.

11 changes: 10 additions & 1 deletion apps/docs/src/guide/getting-started/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Getting Started

This guide will walk you through the process of setting up and using the Fuels-ts library in your front-end project.
Welcome to `fuels` Typescript SDK!

We prepared some guides to walk you through your first steps:

1. [Installation](./installation.md)
1. [Connecting to the Network](./connecting-to-the-network.md)
1. [Running a local Fuel node](./running-a-local-fuel-node.md)
1. [React Example](./react-example.md)
1. [CDN Usage](./cdn-usage.md)
1. [Next Steps](./next-steps.md)
16 changes: 9 additions & 7 deletions apps/docs/src/guide/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@

# Installation

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.
You must install the [Fuel Toolchain](https://docs.fuel.network/guides/installation/) before using this library.

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

::: code-group

```sh-vue [npm]
npm install fuels@{{fuels}} --save
```sh-vue [bun]
bun add fuels@{{fuels}}
```

```sh-vue [pnpm]
pnpm add fuels@{{fuels}}
```

```sh-vue [bun]
bun add fuels@{{fuels}}
```sh-vue [npm]
npm install fuels@{{fuels}} --save
```

:::

**Note**: Use version `{{fuels}}` to ensure compatibility with `testnet` network—check the [docs](https://docs.fuel.network/guides/installation/#using-the-latest-toolchain).
Now you are ready to:

- [Connect to the Network](./connecting-to-the-network.md)
14 changes: 14 additions & 0 deletions apps/docs/src/guide/getting-started/next-steps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Done!

Wait no more, let's build your first Fuel dApp!

- [Creating a Fuel dApp](../creating-a-fuel-dapp/)

## Further Resources

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:

1. Installing all tools needed to develop with the Fuel ecosystem
1. Writing your first Sway Project
1. Deploying your contract
1. Building a simple front-end dApp to interact with your deployed contract
35 changes: 35 additions & 0 deletions apps/docs/src/guide/getting-started/react-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# React Example

<!-- TODO: Create properly code snippet on new package: `app/react-app` after https://github.com/FuelLabs/fuels-ts/pull/827 got merged -->
danielbate marked this conversation as resolved.
Show resolved Hide resolved

```tsx
import { BN, Provider, Wallet } from "fuels";
import { useEffect, useState } from "react";

function App() {
const [balance, setBalance] = useState(0);

useEffect(() => {
const main = async () => {
const provider = await Provider.create(
"https://mainnet.fuel.network/v1/graphql",
);

const wallet = Wallet.fromAddress("0x...", provider);
const { balances } = await wallet.getBalances();

setBalance(new BN(balances[0].amount).toNumber());
};

main();
}, []);

return <div>My Balance: {balance}</div>;
}

export default App;
arboleya marked this conversation as resolved.
Show resolved Hide resolved
```

# More

- [CDN Usage](./cdn-usage.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Running a local Fuel node

Remember to first install the [Fuel Toolchain](https://docs.fuel.network/guides/installation/).

Then check the command self documentation:

::: code-group

```sh-vue [Fuel Binary]
fuel-core
```

<!--
TODO: Uncomment this when `forc node` is available:
- https://github.com/FuelLabs/sway/pull/6473
-->

<!--
```sh-vue [Forc]
forc node
```
-->

```sh-vue [TS SDK]
fuels node
arboleya marked this conversation as resolved.
Show resolved Hide resolved
```

:::

Check also the online docs:

| | Command | Documentation |
| ----------- | ------------ | ------------------------------------------------------------------------------------------------------ |
| Fuel Binary | `fuel-core` | [docs](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) — Running a local node |
| TS SDK | `fuels node` | [docs](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands/#fuels-node) — Using the `fuels` CLI |

<!-- | Forc | `forc node` | [docs](https://docs.fuel.network/docs/forc/commands/forc_node/) | -->

# Testing Utilities

You can run a Fuel node from within your `.ts` unit tests:

- [Launching a test node](../testing/launching-a-test-node.md)

# Developer Utilities

Configure your project for the `fuels` CLI using a `fuels.config.ts` file:

- [Using the `fuels init` command](../fuels-cli/commands.md#fuels-init)

It makes development easier with a hot-reload experience:

- [Using the `fuels dev` command](../fuels-cli/commands.md#fuels-dev)

# More

- [React Example](./react-example.md)
- [CDN Usage](./cdn-usage.md)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// #region main
import { Provider, Wallet } from 'fuels';

import { LOCAL_NETWORK_URL } from '../../../env';
const NETWORK_URL = 'https://mainnet.fuel.network/v1/graphql';
// const NETWORK_URL = 'https://testnet.fuel.network/v1/graphql';
// const NETWORK_URL = 'https://localhost:<port>/v1/graphql';
danielbate marked this conversation as resolved.
Show resolved Hide resolved

const ADDRESS =
'0x767caf5b08eba21c561078a4d5be09bbd7f16b9eca22699a61f1edd9e456126f';

const provider = await Provider.create(LOCAL_NETWORK_URL);
const provider = await Provider.create(NETWORK_URL);
const wallet = Wallet.fromAddress(ADDRESS, provider);

const { balances } = await wallet.getBalances();
Expand Down
50 changes: 0 additions & 50 deletions apps/docs/src/guide/getting-started/usage.md

This file was deleted.

2 changes: 1 addition & 1 deletion apps/docs/src/guide/provider/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Provider

The [`Provider`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html) lets you connect to a Fuel node ([_*local*_](../getting-started/connecting-to-a-local-node.md) or [_*external*_](../getting-started/connecting-to-testnet.md)) and interact with it, encapsulating common client operations in the SDK. Those operations include querying the blockchain for network, block, and transaction-related info (and [more](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html)), as well as sending [transactions](../transactions/index.md) to the blockchain.
The [`Provider`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html) lets you connect to a Fuel node ([_*docs*_](../getting-started/connecting-to-the-network.md)) and interact with it, encapsulating common client operations in the SDK. Those operations include querying the blockchain for network, block, and transaction-related info (and [more](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html)), as well as sending [transactions](../transactions/index.md) to the blockchain.

All higher-level abstractions (e.g. [`Wallet`](../wallets/index.md), [`Contract`](../contracts/index.md)) that interact with the blockchain go through the `Provider`, so it's used for various actions like getting a wallet's balance, deploying contracts, querying their state, etc.

Expand Down
5 changes: 1 addition & 4 deletions apps/docs/src/guide/provider/querying-the-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

Once you have set up a provider, you're ready to interact with the Fuel blockchain.

We can connect to either a _*local*_ or an _*external*_ node:

> 1. _Running a [local node](../getting-started/connecting-to-a-local-node.md)_
> 1. _Connecting to an [external node](../getting-started/connecting-to-testnet.md)_
- [Connecting to the Network](../getting-started/connecting-to-the-network.md)

Let's look at a few examples below.

Expand Down
Loading