From 981b99265a16f66ba0260223796b32b2cfff5223 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 2 Jan 2025 08:19:24 -0300 Subject: [PATCH] docs: improving getting started docs for `mainnet` (#3500) --- .changeset/brave-lies-relax.md | 5 + README.md | 139 ++++++++++-------- apps/docs/.vitepress/config.ts | 20 ++- apps/docs/src/guide/fuels-cli/commands.md | 6 +- .../src/guide/getting-started/cdn-usage.md | 29 ++++ .../connecting-to-a-local-node.md | 10 -- .../getting-started/connecting-to-testnet.md | 22 --- .../connecting-to-the-network.md | 26 ++++ .../getting-started/further-resources.md | 11 -- apps/docs/src/guide/getting-started/index.md | 11 +- .../src/guide/getting-started/installation.md | 16 +- .../src/guide/getting-started/next-steps.md | 14 ++ .../guide/getting-started/react-example.md | 35 +++++ .../running-a-local-fuel-node.md | 35 +++++ .../snippets/connecting-to-localnode.ts | 15 -- .../snippets/connecting-to-testnet.ts | 15 -- .../snippets/connecting-to-the-network.ts | 15 ++ apps/docs/src/guide/getting-started/usage.md | 50 ------- apps/docs/src/guide/provider/index.md | 2 +- .../src/guide/provider/querying-the-chain.md | 5 +- link-check.config.json | 6 + packages/fuels/src/cli.ts | 4 +- scripts/lint-md-links.ts | 3 + 23 files changed, 285 insertions(+), 209 deletions(-) create mode 100644 .changeset/brave-lies-relax.md create mode 100644 apps/docs/src/guide/getting-started/cdn-usage.md delete mode 100644 apps/docs/src/guide/getting-started/connecting-to-a-local-node.md delete mode 100644 apps/docs/src/guide/getting-started/connecting-to-testnet.md create mode 100644 apps/docs/src/guide/getting-started/connecting-to-the-network.md delete mode 100644 apps/docs/src/guide/getting-started/further-resources.md create mode 100644 apps/docs/src/guide/getting-started/next-steps.md create mode 100644 apps/docs/src/guide/getting-started/react-example.md create mode 100644 apps/docs/src/guide/getting-started/running-a-local-fuel-node.md delete mode 100644 apps/docs/src/guide/getting-started/snippets/connecting-to-localnode.ts delete mode 100644 apps/docs/src/guide/getting-started/snippets/connecting-to-testnet.ts create mode 100644 apps/docs/src/guide/getting-started/snippets/connecting-to-the-network.ts delete mode 100644 apps/docs/src/guide/getting-started/usage.md diff --git a/.changeset/brave-lies-relax.md b/.changeset/brave-lies-relax.md new file mode 100644 index 00000000000..88aa3dda2c9 --- /dev/null +++ b/.changeset/brave-lies-relax.md @@ -0,0 +1,5 @@ +--- +"fuels": patch +--- + +docs: improving getting started docs for `mainnet` diff --git a/README.md b/README.md index 7e664aa4544..5a66a712c54 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,107 @@ - - - Fuels-ts SDK logo - +# fuels-ts -**fuels-ts** is a library for interacting with **Fuel v2**. +Typescript SDK for Fuel. [![test](https://github.com/FuelLabs/fuels-ts/actions/workflows/test.yaml/badge.svg)](https://github.com/FuelLabs/fuels-ts/actions/workflows/test.yaml) -[![npm](https://img.shields.io/npm/v/fuels)](https://www.npmjs.com/package/fuels) [![docs](https://img.shields.io/badge/docs-fuels.ts-brightgreen.svg?style=flat)](https://docs.fuel.network/docs/fuels-ts/) +[![npm](https://img.shields.io/npm/v/fuels)](https://www.npmjs.com/package/fuels) [![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe) -# Resources - -The [documentation](https://docs.fuel.network/docs/fuels-ts/) site is your main stop for resources. +# Install ([docs](https://docs.fuel.network/docs/fuels-ts/getting-started/installation)) -- [Quickstart](https://docs.fuel.network/docs/intro/quickstart-contract/) -- [Documentation](https://docs.fuel.network/docs/fuels-ts/) - - [Wallets](https://docs.fuel.network/docs/fuels-ts/wallets/) - - [Contracts](https://docs.fuel.network/docs/fuels-ts/contracts/) - - [Scripts](https://docs.fuel.network/docs/fuels-ts/scripts/) - - [Predicates](https://docs.fuel.network/docs/fuels-ts/predicates/) - - [ABI Typegen](https://docs.fuel.network/docs/fuels-ts/fuels-cli/abi-typegen/) -- [Contributing](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md) -- [The Fuel Forum](https://forum.fuel.network/) -- [The Fuel Ecosystem](#the-fuel-ecosystem) - -# Install - -```sh +```console npm install fuels --save ``` -> 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. +# Connect ([docs](https://docs.fuel.network/docs/fuels-ts/getting-started/connecting-to-the-network/)) -# Import - -Simple example usages. +| Network | URL | +| --------- | --------------------------------------------------------------------------------------------------------------- | +| Mainnet | `https://mainnet.fuel.network/v1/graphql` | +| Testnet | `https://testnet.fuel.network/v1/graphql` | +| Localhost | [Running a local Fuel node](https://docs.fuel.network/docs/fuels-ts/getting-started/running-a-local-fuel-node/) | ```ts -import { Wallet } from "fuels"; +import { Provider } from 'fuels'; -// Random Wallet -console.log(Wallet.generate()); +const NETWORK_URL = 'https://mainnet.fuel.network/v1/graphql'; -// Using privateKey Wallet -console.log(new Wallet("0x0000...0000")); -``` +const provider = await Provider.create(NETWORK_URL); -# CLI +const chainId = provider.getChainId(); +const gasConfig = provider.getGasConfig(); +const baseAssetId = provider.getBaseAssetId(); -Fuels include some utility commands via built-in CLI tool. +console.log({ chainId, gasConfig, baseAssetId }); +``` -Check the [docs](https://docs.fuel.network/docs/fuels-ts/) for more info. +# Create a new dApp ([docs](https://docs.fuel.network/docs/fuels-ts/creating-a-fuel-dapp/)) ```console -$ npm add fuels -$ npx fuels --help -Usage: fuels [options] [command] +$ npm create fuels + +◇ What is the name of your project? # +│ my-fuel-project +└ + +⚡️ Success! Created a fullstack Fuel dapp at: my-fuel-project. +``` -Options: - -D, --debug Enables verbose logging (default: false) - -S, --silent Omit output messages (default: false) - -v, --version Output the version number - -h, --help Display help +# Enjoy the `fuels` CLI ([docs](https://docs.fuel.network/docs/fuels-ts/fuels-cli/)) + +```console +$ npm install fuels --save +$ npm fuels --help Commands: - init [options] Create a sample `fuel.config.ts` file - node [options] Start a Fuel node - dev [options] Start a Fuel node and run build + deploy on every file change - build [options] Build Sway programs and generate Typescript for them - deploy [options] Deploy contracts to the Fuel network - typegen [options] Generate Typescript from Sway ABI JSON files - versions Check for version incompatibilities - help [command] Display help for command + init [options] Create a sample `fuel.config.ts` file + build [options] Build Sway programs and generate Typescript for them + deploy [options] Deploy contracts to the Fuel network + dev [options] Start a Fuel node with hot-reload capabilities + node [options] Start a Fuel node using project configs + typegen [options] Generate Typescript from Sway ABI JSON files + versions [options] Check for version incompatibilities + help [command] Display help for command ``` -# The Fuel Ecosystem +In-depth docs: +- [`fuels init`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-init) — Creates a new `fuels.config.ts` file +- [`fuels build`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-build) — Build `forc` workspace and generate Typescript types for everything +- [`fuels deploy`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-deploy) — Deploy workspace contracts and save their IDs to JSON file +- [`fuels dev`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-dev) — Start a Fuel node with hot-reload capabilities + + +# Official Docs + +- Install The Fuel Toolchain — https://docs.fuel.network/guides/installation/ +--- +- Typescript SDK — https://docs.fuel.network/docs/fuels-ts +- Fuel Wallet SDK — https://docs.fuel.network/docs/wallet +- Rust SDK — https://docs.fuel.network/docs/fuels-rs +- GraphQL Playground — https://docs.fuel.network/docs/graphql +--- +- Forc — https://docs.fuel.network/docs/forc +- Sway — https://docs.fuel.network/docs/sway +- Fuel Core — https://github.com/FuelLabs/fuel-core +- Fuel VM — https://docs.fuel.network/docs/specs/fuel-vm +- Fuel Specs — https://docs.fuel.network/docs/specs + +# Apps & Ecosystem + +- Fuel Bridge — https://app.fuel.network/bridge +- Block Explorer — https://app.fuel.network +- Ecosystem Apps — https://app.fuel.network/ecosystem + +# Get in Touch + +- `Forum` — https://forum.fuel.network +- `Discord` — https://discord.gg/xfpK4Pe + + +# Contribute -Learn more about the Fuel Ecosystem. +- [./CONTRIBUTING.md](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md) -- [🌴 Sway](https://docs.fuel.network/docs/sway/) — The new language, empowering everyone to build reliable and efficient smart contracts -- [🧰 Forc](https://docs.fuel.network/docs/forc/) — The Fuel toolbox: _Build, deploy and manage your sway projects_ -- [⚙️ Fuel Core](https://github.com/FuelLabs/fuel-core) — The new FuelVM, a blazingly fast blockchain VM -- [🔗 Fuel Specs](https://github.com/FuelLabs/fuel-specs) — The Fuel protocol specifications -- [💼 Fuels Wallet](https://github.com/FuelLabs/fuels-wallet) — The Official Fuels Wallet -- [🦀 Rust SDK](https://github.com/FuelLabs/fuels-rs) — A robust SDK in rust -- [⚡ Fuel Network](https://fuel.network/) — The project -- [📚 The Fuel Forum](https://forum.fuel.network/) — Ask questions, get updates, and contribute to a modular future # License diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index f1a007accd1..17fbc9b5931 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -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', }, ], }, diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index d67a4d96ec0..f842abd7a72 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -143,7 +143,11 @@ The `fuels dev` command does three things: npx fuels@{{fuels}} node ``` -The `fuels node` command starts a short-lived `fuel-core` node ([docs](./config-file.md#autostartfuelcore)). +Starts a short-lived `fuel-core` node and requires a `fuels.config.ts` config file. + +Generate one with [`fuels init`](#fuels-init): + +<<< @/../../demo-fuels/fuels.config.minimal.ts#config{ts:line-numbers} ## `fuels typegen` diff --git a/apps/docs/src/guide/getting-started/cdn-usage.md b/apps/docs/src/guide/getting-started/cdn-usage.md new file mode 100644 index 00000000000..7b7e2b850f8 --- /dev/null +++ b/apps/docs/src/guide/getting-started/cdn-usage.md @@ -0,0 +1,29 @@ + + +# CDN Usage (browser only) + +```html-vue + +``` + +# More + +- [React Example](./react-example.md) diff --git a/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md b/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md deleted file mode 100644 index 7a464d19088..00000000000 --- a/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md +++ /dev/null @@ -1,10 +0,0 @@ -# Connecting to a Local Node - -Firstly, you will need a local node running on your machine. We recommend one of the following methods: - -- [Testing utilities](../testing/launching-a-test-node.md) can assist in programmatically launching a short-lived node. -- Running [fuel-core](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) directly. - -In the following example, we create a provider to connect to the local node and sign a message. - -<<< @./snippets/connecting-to-localnode.ts#main{ts:line-numbers} diff --git a/apps/docs/src/guide/getting-started/connecting-to-testnet.md b/apps/docs/src/guide/getting-started/connecting-to-testnet.md deleted file mode 100644 index 188a30b1397..00000000000 --- a/apps/docs/src/guide/getting-started/connecting-to-testnet.md +++ /dev/null @@ -1,22 +0,0 @@ -# Connecting to Testnet - -The **Testnet** is a public network that allows you to interact with a Fuel Virtual Machine and is used for testing and development purposes. - -> [!NOTE] Latest Testnet -> Dev Testnet -> -> `https://testnet.fuel.network/v1/graphql` - -We have some useful resources for the Testnet: - -- [**Faucet**](https://faucet-testnet.fuel.network/) - for funding wallets that have been created. -- [**Explorer**](https://app.fuel.network/) - for viewing transactions and blocks. -- [**GraphQL Playground**](https://testnet.fuel.network/v1/playground) - for testing GraphQL queries and mutations. - ---- - -In the example below, we connect a [Provider](../provider/index.md) to the latest testnet and create a new wallet from a private key. - -> **Note:** New wallets on the Testnet will not have any assets! You can use the [Faucet](https://faucet-testnet.fuel.network/) to fund your wallet. - -<<< @./snippets/connecting-to-testnet.ts#main{ts:line-numbers} diff --git a/apps/docs/src/guide/getting-started/connecting-to-the-network.md b/apps/docs/src/guide/getting-started/connecting-to-the-network.md new file mode 100644 index 00000000000..6ef8d6876fd --- /dev/null +++ b/apps/docs/src/guide/getting-started/connecting-to-the-network.md @@ -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 | diff --git a/apps/docs/src/guide/getting-started/further-resources.md b/apps/docs/src/guide/getting-started/further-resources.md deleted file mode 100644 index 015e4115d1b..00000000000 --- a/apps/docs/src/guide/getting-started/further-resources.md +++ /dev/null @@ -1,11 +0,0 @@ -# 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/). This guide covers: - -1. Installing all tools needed to develop with the Fuel ecosystem. - -2. Writing your first Sway Project. - -3. Deploying your contract. - -4. Building a simple front-end dApp to interact with your deployed contract. diff --git a/apps/docs/src/guide/getting-started/index.md b/apps/docs/src/guide/getting-started/index.md index cbb43088ec9..d818f5891fb 100644 --- a/apps/docs/src/guide/getting-started/index.md +++ b/apps/docs/src/guide/getting-started/index.md @@ -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) diff --git a/apps/docs/src/guide/getting-started/installation.md b/apps/docs/src/guide/getting-started/installation.md index 51520e763aa..6472bb7ef1d 100644 --- a/apps/docs/src/guide/getting-started/installation.md +++ b/apps/docs/src/guide/getting-started/installation.md @@ -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) diff --git a/apps/docs/src/guide/getting-started/next-steps.md b/apps/docs/src/guide/getting-started/next-steps.md new file mode 100644 index 00000000000..c6fc3d0732d --- /dev/null +++ b/apps/docs/src/guide/getting-started/next-steps.md @@ -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 diff --git a/apps/docs/src/guide/getting-started/react-example.md b/apps/docs/src/guide/getting-started/react-example.md new file mode 100644 index 00000000000..ff9c3dfebed --- /dev/null +++ b/apps/docs/src/guide/getting-started/react-example.md @@ -0,0 +1,35 @@ +# React Example + + + +```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
My Balance: {balance}
; +} + +export default App; +``` + +# More + +- [CDN Usage](./cdn-usage.md) diff --git a/apps/docs/src/guide/getting-started/running-a-local-fuel-node.md b/apps/docs/src/guide/getting-started/running-a-local-fuel-node.md new file mode 100644 index 00000000000..97cda0bd168 --- /dev/null +++ b/apps/docs/src/guide/getting-started/running-a-local-fuel-node.md @@ -0,0 +1,35 @@ +# Running a local Fuel node + +Remember to first install the [Fuel Toolchain](https://docs.fuel.network/guides/installation/). + +Check 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 | + + + +# Utilities + +## Testing + +You can run a Fuel node from within your `.ts` unit tests: + +- [Launching a test node](../testing/launching-a-test-node.md) + +## Developing + +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) diff --git a/apps/docs/src/guide/getting-started/snippets/connecting-to-localnode.ts b/apps/docs/src/guide/getting-started/snippets/connecting-to-localnode.ts deleted file mode 100644 index 32d26a15e26..00000000000 --- a/apps/docs/src/guide/getting-started/snippets/connecting-to-localnode.ts +++ /dev/null @@ -1,15 +0,0 @@ -// #region main -import { Provider, Wallet } from 'fuels'; - -import { LOCAL_NETWORK_URL } from '../../../env'; - -const ADDRESS = - '0x767caf5b08eba21c561078a4d5be09bbd7f16b9eca22699a61f1edd9e456126f'; - -const provider = await Provider.create(LOCAL_NETWORK_URL); -const wallet = Wallet.fromAddress(ADDRESS, provider); - -const { balances } = await wallet.getBalances(); - -console.log('Balances', balances); -// #endregion main diff --git a/apps/docs/src/guide/getting-started/snippets/connecting-to-testnet.ts b/apps/docs/src/guide/getting-started/snippets/connecting-to-testnet.ts deleted file mode 100644 index c47478ff548..00000000000 --- a/apps/docs/src/guide/getting-started/snippets/connecting-to-testnet.ts +++ /dev/null @@ -1,15 +0,0 @@ -// #region main -import { Provider, Wallet } from 'fuels'; - -const ADDRESS = - '0x767caf5b08eba21c561078a4d5be09bbd7f16b9eca22699a61f1edd9e456126f'; - -const provider = await Provider.create( - 'https://testnet.fuel.network/v1/graphql' -); -const wallet = Wallet.fromAddress(ADDRESS, provider); - -const { balances } = await wallet.getBalances(); - -console.log('Balances', balances); -// #endregion main diff --git a/apps/docs/src/guide/getting-started/snippets/connecting-to-the-network.ts b/apps/docs/src/guide/getting-started/snippets/connecting-to-the-network.ts new file mode 100644 index 00000000000..b2b15b996c2 --- /dev/null +++ b/apps/docs/src/guide/getting-started/snippets/connecting-to-the-network.ts @@ -0,0 +1,15 @@ +// #region main +import { Provider } from 'fuels'; + +const NETWORK_URL = 'https://mainnet.fuel.network/v1/graphql'; + +const provider = await Provider.create(NETWORK_URL); + +const baseAssetId = provider.getBaseAssetId(); +const chainId = provider.getChainId(); +const gasConfig = provider.getGasConfig(); + +console.log('chainId', chainId); +console.log('baseAssetId', baseAssetId); +console.log('gasConfig', gasConfig); +// #endregion main diff --git a/apps/docs/src/guide/getting-started/usage.md b/apps/docs/src/guide/getting-started/usage.md deleted file mode 100644 index 5e6d24d5962..00000000000 --- a/apps/docs/src/guide/getting-started/usage.md +++ /dev/null @@ -1,50 +0,0 @@ -# Usage - -With the Fuels dependency set up, you can now create a React component that will connect to the Fuel provider and retrieve the base asset balance for a given wallet address. Here's an example of how to do this: - - - -```tsx -import { BN, Provider, Wallet } from "fuels"; -import { useEffect, useState } from "react"; - -function App() { - const [balance, setBalance] = useState(0); - - useEffect(() => { - async () => { - const provider = await Provider.create("https://testnet.fuel.network/v1/graphql"); - const myWallet = Wallet.fromAddress("0x...", provider); - myWallet.getBalances().then((data) => { - setBalance(new BN(data[0].amount).toNumber()); - }); - }() - }, []); - - return
My Balance: {balance}
; -} - -export default App; -``` - -## CDN Usage (browser only) - -For a quick test or just playing around, you can load it in your Web Apps straight from our CDN. - -```html - -``` diff --git a/apps/docs/src/guide/provider/index.md b/apps/docs/src/guide/provider/index.md index 6b004bf3d7b..d8a09b86e83 100644 --- a/apps/docs/src/guide/provider/index.md +++ b/apps/docs/src/guide/provider/index.md @@ -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. diff --git a/apps/docs/src/guide/provider/querying-the-chain.md b/apps/docs/src/guide/provider/querying-the-chain.md index 0533208a857..f8ebcc10f6a 100644 --- a/apps/docs/src/guide/provider/querying-the-chain.md +++ b/apps/docs/src/guide/provider/querying-the-chain.md @@ -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. diff --git a/link-check.config.json b/link-check.config.json index b269b14e999..8ce8f969d75 100644 --- a/link-check.config.json +++ b/link-check.config.json @@ -7,6 +7,12 @@ "ignorePatterns": [ { "pattern": "^http://localhost:3000" + }, + { + "pattern": "https://docs.fuel.network/docs/fuels-ts/getting-started/connecting-to-the-network" + }, + { + "pattern": "https://docs.fuel.network/docs/fuels-ts/getting-started/running-a-local-fuel-node" } ] } diff --git a/packages/fuels/src/cli.ts b/packages/fuels/src/cli.ts index eb02468b6e7..0299c304750 100644 --- a/packages/fuels/src/cli.ts +++ b/packages/fuels/src/cli.ts @@ -68,12 +68,12 @@ export const configureCli = () => { .action(withProgram(command, Commands.init, init)); (command = program.command(Commands.dev)) - .description('Start a Fuel node and run build + deploy on every file change') + .description('Start a Fuel node with hot-reload capabilities') .addOption(pathOption) .action(withConfig(command, Commands.dev, dev)); (command = program.command(Commands.node)) - .description('Start a Fuel node') + .description('Start a Fuel node using project configs') .addOption(pathOption) .action(withConfig(command, Commands.node, node)); diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index 20c04136b27..a530688d5a1 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -9,6 +9,9 @@ const { log } = console; ignore: ['**/node_modules/**', 'apps/demo-*/**', '.changeset/**', '**/CHANGELOG.md'], }); + // TODO: Stop ignoring doc links in `link-check.config.json` + // The above requires this to be merged and deployed: + // - https://github.com/FuelLabs/fuels-ts/pull/3500 try { execSync(`pnpm markdown-link-check -q -c ./link-check.config.json ${mdFiles.join(' ')}`, { stdio: 'inherit',