///
The Quicksilver SDK transforms complex financial logic into elegant, type-safe code using a fluent Domain-Specific Language (DSL). This page provides runnable examples demonstrating how to define soph
42 views
~42 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 transforms complex financial logic into elegant, type-safe code using a fluent Domain-Specific Language (DSL). This page provides runnable examples demonstrating how to define sophisticated conditional transactions and programmable products.
You can learn more about the underlying DSL builders in the [API Reference - DSL Builders] page.
This example demonstrates how to set up a milestone-based escrow transaction. Funds are held and then automatically released based on predefined conditions, eliminating the need for manual intervention or complex backend logic. This uses the client.condition() builder to define the rules and Action.release() and Action.notify() to specify outcomes.
This example showcases:
client.condition(): The entry point for defining conditional logic..when(QuickSilverEvent.MilestoneApproved, ctx => ctx.milestone === 'design'): Defines a specific trigger. It listens for the MilestoneApproved event and further refines it with a predicate function to check if the milestone context variable is 'design'..then(Action.release(1000).to(freelancerAccount.id)): Specifies actions to take when the when condition is met. Here, it uses Action.release() (which returns an ActionBuilder) to fluently define releasing $1000 to the freelancer..then(Action.notify(clientAccount.id, '...')): Another action to notify the client. Action.notify() returns a simple Action object..otherwise(Action.hold('...')): A fallback action to hold funds if none of the preceding when conditions are met.projectCondition.getConditions(): Compiles the fluent builder chain into a structured array of conditions, ready for API transmission.This example demonstrates how to define and purchase programmable products, encapsulating their pricing, guarantees, and even multi-agent workflows into a single, reusable entity. It uses the client.product() builder to create these sophisticated definitions.
This comprehensive example illustrates:
client.product('ai-translation-en-es'): The fluent entry point for defining a new programmable product with a unique ID..charge(0.01, 'per_word'): Defines a unit-based pricing model, clearly stating the rate and the unit of charge..guarantee({ accuracy: 0.98, turnaround: '5 minutes' }): Attaches service level guarantees directly to the product definition..stage('research', { delegateTo: researchAgent.id, charge: 20 }): Defines stages for multi-agent workflows, specifying which agent handles each stage and its associated cost. This allows for complex processes to be encapsulated and executed as a single product..stream(0.001, 'per_second'): Defines a streaming pricing model for continuous services.customer.purchase(translationService, { ...options }): An Account model method to purchase a defined product, triggering a transaction with all the product's inherent logic and configurations.product.getPricing(), product.getGuarantees(), product.getWorkflow(): Methods on the ProductBuilder (which acts as the Product itself) to retrieve its defined characteristics, enabling powerful analytics and monitoring of product definitions.These examples highlight how Quicksilver's DSL transforms financial transactions from static data structures into dynamic, intelligent, and programmable money primitives.