circle-check
Our docs are AI-ready. Use them as context for any AI, or ask questions via the search bar.

playIntroduction

A production-ready set of React blocks for integrating Trustless Work’s escrow flows.

circle-info

Want to customize the blocks?

Edit the generated components however you want.


What you get

  • UI blocks (cards/tables/dialogs/forms) to list and manage escrows

  • Providers for API config, wallet context, dialogs and amounts

  • TanStack Query hooks for fetching and mutating escrows

  • Wallet-kit helpers and error handling utilities

List all available blocks

Use the CLI to print all available blocks:

This is the fastest way to discover folder paths for npx trustless-work add ....

Context API

The context API is a global storage of escrows. It is used to store the escrows that are fetched from the API. It is also used to store the selected escrow.

circle-info

You don’t have to use this context approach.

You can use Redux, Zustand, or anything else. Just make sure the target escrow data is available to each endpoint hook.

How the context is used by endpoint hooks

When implementing the endpoints, we need to pass the data of a specific escrow to each endpoint. But how do we do that? Our library provides a context called EscrowContext, which includes some very important utilities. Among them areselectedEscrowand setSelectedEscrow, which allow us to do the following:

selectedEscrow

Currently, selectedEscrow holds a specific escrow that we are pointing to. With this, all the endpoint hooks interact with that state in order to extract data from it, such as contractId, roles, etc. For example, in the change status select, the milestoneIndex values are loaded based on the currently selected escrow. Therefore, ifsetSelectedEscrow is undefined, they won't load.

setSelectedEscrow

setSelectedEscrow stores the selected escrow in context.

Other hooks and UI blocks can then read selectedEscrow to get contractId, roles, etc. Example: cards view stores the selected escrow before opening the details dialog.

updateEscrow

Our updateEscrow function update the existing selectedEscrow in the context. It is useful to update a flag or others fields. For example, we use it to update the escrow status after a change milestone status mutation.

Install blocks by folder path

You can install whole folders (and all child blocks) with one command.

Install a parent directory

Installs all escrow blocks.

Install a specific subfolder

Installs only single-release escrow blocks.

circle-check

Installation Guidearrow-up-right

Last updated

Was this helpful?