Skip to content

Conversation

zees-dev
Copy link
Contributor

@zees-dev zees-dev commented Sep 9, 2025

Description

This PR adds support for directly funding accounts when starting a local Fuel node with forc-node, eliminating the need to manually edit chainspec files - via specifying --account parameter.

Changes

  • Added --account flag to forc-node local command that supports multiple funding formats:
    • <account-id> - funds account with base asset and default amount
    • <account-id>:<asset-id> - funds account with specified asset and default amount
    • <account-id>:<asset-id>:<amount> - funds account with specified asset and amount

Usage Examples

# Fund single account with default asset and amount
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610

# Fund account with custom asset
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610:0x0000000000000000000000000000000000000000000000000000000000000002

# Fund account with custom asset and amount
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610:0x0000000000000000000000000000000000000000000000000000000000000002:1000000

# Fund multiple accounts
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610 \
  --account 0xe10f526b192593793b7a1559a391445faba82a1d669e3eb2dcd17f9c121b24b1

CLI output

Screenshot 2025-09-10 at 11 15 41 AM
  • 5 Initial/funded accounts are provided by forc-node (default 5)
  • Additional accounts are user provided (optional)
    • These are introduced in this PR

Implementation Details

  • Default amount uses TESTNET_INITIAL_BALANCE constant when not specified
  • Default asset uses the chain's base asset ID when not specified

Addresses: #7317

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@zees-dev zees-dev self-assigned this Sep 9, 2025
@zees-dev zees-dev requested a review from a team as a code owner September 9, 2025 06:23
@zees-dev zees-dev added enhancement New feature or request dev-experience Anything to do with the developer experience team:tooling Tooling Team forc-node Everything related to forc-node, bootstrapping a fuel-core node labels Sep 9, 2025
Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@JoshuaBatty JoshuaBatty requested a review from a team September 10, 2025 00:06
@zees-dev zees-dev merged commit 3210f94 into master Sep 11, 2025
39 checks passed
@zees-dev zees-dev deleted the feat/forc-node-fund-accounts branch September 11, 2025 03:36
zees-dev added a commit that referenced this pull request Sep 25, 2025
Elaela22soL pushed a commit to Elaela22soL/sway that referenced this pull request Sep 26, 2025
## Description

This PR adds support for directly funding accounts when starting a local
Fuel node with `forc-node`, eliminating the need to manually edit
chainspec files - via specifying `--account` parameter.

## Changes

- Added `--account` flag to `forc-node local` command that supports
multiple funding formats:
  - `<account-id>` - funds account with base asset and default amount
- `<account-id>:<asset-id>` - funds account with specified asset and
default amount
- `<account-id>:<asset-id>:<amount>` - funds account with specified
asset and amount

## Usage Examples

```bash
# Fund single account with default asset and amount
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610

# Fund account with custom asset
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610:0x0000000000000000000000000000000000000000000000000000000000000002

# Fund account with custom asset and amount
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610:0x0000000000000000000000000000000000000000000000000000000000000002:1000000

# Fund multiple accounts
forc-node local \
  --account 0x54944e5b8189827e470e5a8bacfc6c3667397dc4e1eef7ef3519d16d6d6c6610 \
  --account 0xe10f526b192593793b7a1559a391445faba82a1d669e3eb2dcd17f9c121b24b1
```

## CLI output

<img width="1304" height="254" alt="Screenshot 2025-09-10 at 11 15
41 AM"
src="https://github.com/user-attachments/assets/add420e5-a64e-4c82-8605-99aeba7e878a"
/>

- 5 Initial/funded accounts are provided by forc-node (default 5)
- Additional accounts are user provided (optional)
  - These are introduced in this PR

## Implementation Details

- Default amount uses `TESTNET_INITIAL_BALANCE` constant when not
specified
- Default asset uses the chain's base asset ID when not specified

Addresses: FuelLabs#7317

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: z <zees-dev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-experience Anything to do with the developer experience enhancement New feature or request forc-node Everything related to forc-node, bootstrapping a fuel-core node team:tooling Tooling Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants