FuelLabs / fuels-ts

Fuel Network Typescript SDK
https://docs.fuel.network/docs/fuels-ts/
Apache License 2.0
44.26k stars 1.34k forks source link

Complex tx example dApp #2850

Open danielbate opened 1 month ago

danielbate commented 1 month ago

@SilentCicero has requested a complex example dApp to support devrel:

It should have the following spec

  1. Templated with create fuels for local development support
  2. Replace the counter contract with a token minter contract (multi asset example in sway-playground for context)
  3. Introduce 4 predicates in 4 additional, separate workspaces. Each predicate can be very simple as follows:
predicate;

configurable {
    INDEX: u64 = 1,
}

fn main(input: u64) -> boolean {
    input === INDEX
}
  1. In the dApp, it should send the following transactions which will produce a 3 kinds (two fungible / one NFT) of tokens to specific predicate addresses:
  • Send/mint fungible 10,000 asset A to predicate A
  • Send/mint fungible 10,000 asset B to predicate A
  • Send/mint fungible 5000 asset A to predicate B
  • Send/mint fungible 5000 asset B to predicate C
  • Send/mint 1 non-fungible asset to predicate D
  1. Create a tx that utilises and attempts to spend all the assets from the previous txs via the predicate code.
maschad commented 1 month ago

Discussed in our weekly sync on 29-07-2024, but as suggested by @danielbate and @arboleya perhaps the before creating another example dApp, given we currently already maintain two, we could explore the possibility of covering such an advanced use case in the cookbook, similar to how we conduct such a complex transaction using doc snippets such as one with multiple signers. This example essentially highlights a complex use of scripts and multiple UTXOs. At the very least this could the precursor for the example dApp.

danielbate commented 1 month ago

Given the above comment and #2864, moving this to p2

arboleya commented 1 month ago

@danielbate If #2864 suffices, we can safely close this issue.