sway/docs
zees-dev d6410e37f0
Forc call transfers (#7056)
## Description

Implementation of direct transfer of assets to an address using
`forc-call` binary.
Refactor of the `forc-call` binary since it now supports 3 code paths:
- calling (query or tx submission) contracts
- transferring assets directly to an address (recipient and/or contract)
- listing contract functions with call examples

## Usage

```sh
# transfer default asset (eth) to `0x2c7Fd852EF2BaE281e90ccaDf18510701989469f7fc4b042F779b58a39919Eec`
forc-call 0x2c7Fd852EF2BaE281e90ccaDf18510701989469f7fc4b042F779b58a39919Eec --amount 2 --mode=live
```

### Output

```log
warning: No signing key or wallet flag provided. Using default signer: 0x6b63804cfbf9856e68e5b6e7aef238dc8311ec55bec04df774003a2c96e0418e

Transferring 2 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07 to recipient address 0x2c7fd852ef2bae281e90ccadf18510701989469f7fc4b042f779b58a39919eec...

tx hash: e4e931276a500cce1b5303cb594c0477968124ab0f70e77995bbb4499e0c3350
```

## Additional notes

- Inspired by `cast send` where if the CLI is called without a function
signature, it transfers value (eth) to the target address based on the
`--value` parameter; `forc-call` does the same via the `--amount` param
- One can specify the `asset` to be sent; defaults to native network
asset (`eth`)
- Transfers only work with `--mode=live`; since there is no
simulation/dry-run functionality available for this
- Transfers to both contracts and user recipients is supported

## Checklist

- [ ] 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>
Co-authored-by: kaya <kaya.gokalp@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2025-04-06 23:38:47 -07:00
..
book Forc call transfers (#7056) 2025-04-06 23:38:47 -07:00
reference Defining, parsing, and checking #[attribute]s (#6986) 2025-03-24 09:34:31 +11:00
slides Merge std and core libraries (#6729) 2025-03-12 23:52:38 +01:00
breaking-release-checklist.md Add "Breaking Release Checklist" to internal docs (#6980) 2025-03-04 11:16:51 +01:00
internals.md Implements fully working hierarchical lexical scopes. (#6784) 2025-01-13 11:02:20 +11:00