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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 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,24 @@
# CDN Usage (browser only)

```html
<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,34 @@
# 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:

| Mainnet | Testnet |
| ----------------------------------------- | ----------------------------------------- |
| `https://mainnet.fuel.network/v1/graphql` | `https://testnet.fuel.network/v1/graphql` |

You can also connect to `localhost`:

- [Running a local Fuel node](./running-a-local-fuel-node.md)

# Resources

You can also 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 |

# Next

You can also connect to `localhost`:

- [Running a local Fuel node](./running-a-local-fuel-node.md)
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 a couple 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 details 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 -->

```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;
```

# More

- [CDN Usage](./cdn-usage.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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
```

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

```sh-vue [TS SDK]
fuels node
```

:::

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';

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