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

Skip to main content

Processing Orders

This guide covers how to use tbDEX to communicate about progress on Orders you receive.

Provide an Initial OrderStatus

Your business logic for handling an incoming order should be placed in your server's onSubmitOrder() callback parameter. As a best practice, you'll want to first store your Order message in your Exchanges database.

Upon storing the Order message, you will want to create an initial OrderStatus to update the Wallet on the status of their Order:

JavaScript
Kotlin
Swift

If the Wallet Application supplied a replyTo address, you'll send the OrderStatus message there. You can also write the OrderStatus to your database and the Wallet will poll for OrderStatus data.

Process the Order

The Order message will contain the information you initially stored in an Offering object that will specify the pay-in, pay-out, and rate of conversion needed.

Using that information, you’ll be able to use your logic of choice to actually fulfill that order for your customer.

note

tbDEX is a messaging protocol that facilitates communication to enable transactions but does not actually provide the APIs to fulfill them. That responsibility lies with the transacting parties.

As you deem appropriate for your customers, you can provide them with multiple OrderStatus messages using the same code as in the section above.

Close the Order

When the Order has reached a terminal state (e.g. order fulfilled, order rejected, etc), you can create a Close message, which will be the final message of the thread.

JavaScript
Kotlin
Swift

After writing the Close message to your database, the Wallet will be able to know that their transaction has closed via polling or callback.

Connect with us on Discord

Submit feedback: Open a GitHub issue

Edit this page: GitHub Repo

Contribute: Contributing Guide