Escrow's Single Release Lifecycle
Step by Step Guide to implement Escrow's Single Release Lifecycle
Important
It does not work for a real use case, only for testing purposes. But if you want to implement it, you can use the code below as a reference and customize it to your needs.
Create a Next.js Project#
Start by creating a new Next.js project with TypeScript and Tailwind CSS. In order to make easier the setup, please use the path alias with "@/":
npx create-next-app@latestNavigate to your project directory:
cd my-trustless-appInstall Trustless Work Blocks#
Install the main library package:
npm
npm install @trustless-work/blocksRun the CLI Setup
Initialize your project with the Trustless Work CLI:
npx trustless-work initWhat the init command does:
Installs shadcn/ui components (with interactive prompts)
Installs required dependencies: @tanstack/react-query, @trustless-work/escrow, axios, zod, react-hook-form, @creit.tech/stellar-wallets-kit, react-day-picker, etc.
Creates
.twblocks.jsonconfiguration fileOptionally wires providers into your Next.js
app/layout.tsx
Environment Configuration
Create a .env file in your project root:
.env
Add Wallet Connectivity
Add wallet connectivity to your app:
Wrap your app with the WalletProvider:
Wrap your app with the WalletProvider in your layout.tsx:
app/layout.tsx
Example usage in a page:
Add wallet connectivity to your app:
app/page.tsx
Add Helpers
Add helpers to your app:
Add Tanstack Query
Add Tanstack Query to your app:
Add Handle Errors
Add Handle Errors to your app:
Add Providers (If you skipped the init command)
Add Providers to your app:
Add Single Release Escrows Components
Add Single Release Escrows to your app:
Add Single-Multi Release Escrows Components
Add Single-Multi Release Escrows to your app:
Add Escrows by Role Cards
Add Escrows by Role Cards to your app:
Import Actions
In the code, there are some actions commented out. You can uncomment them and import them from the single-release block. See the notes in the escrows by role or by signer components.
Commented Out Code
escrows/escrows-by-role/details/Actions.tsx
Actions Imported
escrows/escrows-by-role/details/Actions.tsx
Manual Provider Setup
Wrap your app with the required providers in this specific order:
app/layout.tsx
Provider Order MattersThe providers must be nested in this exact order for proper functionality.
Example usage in a page:
Now, you are able to interact with the entire escrow lifecycle.
app/page.tsx
All the blocks were added, now use them!You already have all the required blocks to start using the single-release escrow lifecycle.
Final UI
By using these components, you'll be able to completed the entire escrow lifecycle.
Important Usage Advice- This cards components works by role. In the filters section, you can select the role you want to see the escrows for. Based on that, the actions buttons will be rendered. - Before you start using the UI, you must add the USDC asset to your wallet. If not, you wont be able to interact with Trustless Work.
Wallet Connection Dialog
Show the wallet connection dialog:

Cards by Role
Show the cards by role:

Initialize Escrow Dialog
Show the initialize escrow dialog:

Escrow Details Dialog
Show the escrow details dialog:

The easiest way to implement escrows in blockchain."
Last updated
Was this helpful?