.. and press ENTER to ask a question on web5, how to write code and more.

Skip to main content

Creating Quotes

When you receive an RFQ message, you’ll want to do the following:

  1. Store the RFQ message in your database
  2. Get the Offering specified by offeringId in the RFQ
  3. Create a Quote and store it in your database

Store RFQ message

An RFQ is the first message of an exchange. When a Wallet application sends your PFI an RFQ message, your server's onCreateExchange() callback parameter will be invoked. This is where you should implement your business logic for determining the customer's exact Quote.

As a best practice, store the RFQ message in your Exchanges database so that both you and the Wallet app can access it.

Get the Offering

After inserting the RFQ into your database, you can search your database for the Offering the RFQ is requesting.

RFQs contain a required offeringId field that you pass to your Offerings API provider’s getOffering() method to obtain the exact Offering.

Building on the example from the Exchange API Provider section, your code might look like this:

JavaScript
Kotlin
Swift

Verify Credentials

Upon receiving an RFQ, the tbDEX SDK will automatically verify the submitted credentials to guarantee their integrity and authenticity as well as ensure that they meet the requiredClaims specified in the Offering.

Create a Quote

Before creating a Quote in response to the received RFQ, you can review the protocol definition for Quotes. With that in mind, you can then create your quote using the Quote.create() method as shown below:

JavaScript
Kotlin
Swift

With the Quote created, you’ll then sign it for authorization purposes and write it to your own database:

JavaScript
Kotlin
Swift
Note

If the Wallet Application supplied a replyTo address with their RFQ, the tbDEX SDK will send the Quote to that address.

If not, the Wallet Application will poll your PFI awaiting the Quote message to appear within the exchange.

Connect with us on Discord

Submit feedback: Open a GitHub issue

Edit this page: GitHub Repo

Contribute: Contributing Guide