This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
3,410 additions
and
1,074 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Predicates | ||
|
||
## Definition | ||
|
||
- Immutable and ephemeral. | ||
- [Read more on predicates here](#). | ||
|
||
- Predicates are one of the most important abstractions that Fuel makes availabe. A predicate effectively has two states: a _created_ state, and a _spent_ state. A predicate has a `created` state when the predicate is...created. | ||
|
||
- A predicate becomes "created" when a given UTXO inclues certain parameters in its [witness data](./transactions.md). | ||
- A predicate becomes "spent" when the aforementioned UTXO is used as an input into a subsequent [Transaction](./transactions.md), where this subsequent Transaction also includes certain parameters in its witness data. | ||
|
||
> TLDR: A predicate is a UTXO that includes extra information sent in the Transaction. | ||
```rust,ignore | ||
/// Standardized `Witness` data format for predicates. | ||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct Predicate { | ||
/// ID of predicate. | ||
id: UID, | ||
/// Commitment of the predicate template used. | ||
template_commitment: Bytes32, | ||
/// Configurable constants in predicates. | ||
configuration_schema: Vec<u8>, | ||
} | ||
/// Representation of a `Predicate`. | ||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct Predicate { | ||
/// ID of predicate. | ||
id: UID, | ||
/// Standardized witness data format | ||
witness_data: Predicate, | ||
coin_input: Option<InputCoin>, | ||
coin_output: CoinOutput, | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
In order to get started indexing Predicates, users will need to: | ||
|
||
1. Create a new Predicate project using [`forc`] | ||
2. Build this predicate project in order to get the JSON ABI. | ||
3. Add this predicate template hash to your indexer manifest. | ||
4. Include the appropriate witness data in transactions you wish to flag to your indexer | ||
|
||
```rust,ignore | ||
extern crate alloc; | ||
use fuel_indexer_utils::prelude::*; | ||
#[indexer(manifest = "indexer.manifest.yaml")] | ||
mod indexer_mod { | ||
fn handle_spent_predicates(predicates: Vec<Predicate>) { | ||
unimplemented!() | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.