FuelLabs / FuelLabs/forc

`forc-client` - support working with predicates

Open
#160 0 comments 0 reactions 1 assignee Claimed by @kayagokalp View on GitHub
enhancement forc forc-client
Dominant language
Rust
Stars
0
Forks
0
Avg merge
1d 22h
Merged PRs (30d)
3

Description

## Predicates

My understanding of the way predicates work is still a little fuzzy, but I believe the essence is this:

1. **Predicates have addresses.**
- Basically, the hash of their bytecode, similar to contracts.
2. **A user can send some resources _to_ a predicate.**
- All that is required is a wallet with funds, the predicate address and a script transaction.
3. **A user can attempt to spend resources _from_ a predicate.**
- The predicate bytecode must be provided as a part of the script transaction input.
- Similarly, predicate input data can be provided (basically predicate main function args?).
- The input predicates will be executed prior to the script.
- The script execution (and in turn, the spend) only occurs if the predicates evaluate to `true`.

Ideally, we should support all of the above via the `forc-client` CLI.

### 1. Predicate Addresses

This could be a simple `forc predicate-id` command (#3444), or outputting the ID to the `out/` directory as a part of `forc build` (or both).

### 2. Sending resources to a predicate

This should be possible today using `forc run` with a custom script that does the send.

Ideally, `forc-wallet` would make it easier to send funds with something like `forc wallet send ...`. I've opened https://github.com/FuelLabs/forc/issues/80.

### 3. Spending a predicate

To begin, I think the main thing we want to support here is specifying predicates via the `forc run` command. E.g. something like:

```console
forc run --predicate ./out/debug/predicate.bin --predicate-data "arg1 arg2 arg3"
```

- The `--predicate` flag points to some predicate bytecode.
- The `--predicate-data` flag provides some predicate input data. We could expand on this with something similar to FuelLabs/forc#196.

We could potentially allow for multiple predicates by always requiring that the `--predicate-data` flag immediately follows the `--predicate` flag, and then simply allow for specifying multiple `--predicate` flags.

We could also optionally allow for specifying the predicate address via a `--predicate-id` flag, as a kind of sanity check to ensure that the bytecode pointed to is indeed the correct predicate.

---

cc @simonr0204 I remember we talked very briefly about some ideas for working with predicates via the CLI - feel free to add any thoughts/ideas here!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.