///
The Quicksilver SDK empowers developers to create sophisticated financial interactions, such as conditional escrow, using a fluent and type-safe Domain-Specific Language (DSL). This example demonstrat
74 views
~74 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The Quicksilver SDK empowers developers to create sophisticated financial interactions, such as conditional escrow, using a fluent and type-safe Domain-Specific Language (DSL). This example demonstrates how to define conditional logic, create an escrow transaction, and arm that logic to react to external events.
This example showcases the core vision of Quicksilver: transforming complex financial contracts into elegant, readable code. Specifically, it illustrates:
client.condition() builder to express "if-then-otherwise" rules without dealing with raw, error-prone JSON.Escrow transaction directly from an active Account Model and link it to the previously defined conditional logic.QuickSilverEvents to trigger its predefined actions.This provides a powerful primitive for programmable money, where funds are held and released automatically based on real-world or system events.
examples/3-conditional-escrow.tsQuickSilverEvent and Action BuildersThe elegance of conditional logic in Quicksilver SDK comes from the interplay of QuickSilverEvent and the Action builders, all managed by the ConditionBuilder.
QuickSilverEvent: This is an enumeration of predefined events that the Quicksilver Engine listens for. When you define a condition using .when(QuickSilverEvent.MilestoneApproved, ...), you're telling the engine to check this condition specifically when a milestone_approved event occurs. The event context (ctx) provides additional data related to the event (e.g., ctx.milestone === 'design'), allowing for granular control.
Action Builders: The Action class (and its fluent ActionBuilder counterpart) provides a way to define what should happen when a condition is met.
Action.release(amount).to(accountId): This creates an instruction to release a specified amount of funds to a target accountId. The .to() method is part of ActionBuilder's fluent interface, allowing you to chain the recipient specification directly.Action.notify(accountId, message): This creates an instruction to send a notification to a specific account with a given message.Action.hold(message): This instructs the engine to keep the funds on hold and provides a message explaining the current status.By combining QuickSilverEvent with Actions via the ConditionBuilder, you construct a powerful rule engine that automates financial flows based on specific criteria and triggers.
For more details on setting up your client and basic account operations, refer to the Getting Started guide. To understand the underlying objects, consult the API Reference: Account Model and API Reference: Transaction Model.