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,734 additions
and
1,294 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,56 @@ | ||
# Predicates | ||
|
||
## Definition | ||
|
||
- Immutable and ephemeral. | ||
- 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 IndexerPredicate { | ||
/// Hash of associated predicate bytecode | ||
template_id: Bytes32, | ||
/// Configurable constants in predicates. | ||
configurables: Vec<u8>, | ||
/// Relevant TX output indices of predicates that need to be watched. | ||
output_index: u64, | ||
/// UTXO held by predicate. | ||
coin_output: CoinOutput, | ||
/// ID of transaction in which predicate was created. | ||
unspent_tx_id: Bytes32, | ||
/// ID of transaction in which predicate was spent. | ||
spent_tx_id: Option<Bytes32>, | ||
} | ||
``` | ||
|
||
## 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<IndexerPredicate>) { | ||
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
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.