Outgoing TRP Transactions
Setting the Scene
In this scenario, your customer is the originator. The customer wants to withdraw funds to a beneficiary who is a customer of a third party VASP, a.k.a. a counterparty VASP.
In this guide, the necessary steps are listed to integrate the described scenario using the 21 Travel Rule GraphQL API.
Add Support for Travel Address in UI
The customer facing UI needs to accept Travel Addresses. In this example, we re-use the same field for Travel Addresses as well as wallet addresses. It will become evident how both can be supported in the same field later in this guide.
Now, your customer is able to paste Travel Addresses he has received from the person or entity he wants to pay.
Validate Travel Address
Use the { trpd { validateTravelAddress } }
query to validate your customer's
input. If it returns an error, you can conclude that the user has pasted a
wallet address. If it doesn't return an error you can skip ahead to the next
section to proceed.
If the customer has pasted a wallet address, you can use the
{ trpd { lookupAddressDirectory } }
query to check if a Travel Address can be
found for that wallet address. In case the query returns null
you need to fall
back to email. Otherwise, you can proceed to
the next section.
Initiate TRP Interaction
Now, you can initiate the TRP interaction with the counterparty using the
{ trpd { inquire } }
mutation. It takes the Travel Address as an argument and
also details such as the beneficiary name you have obtained from your customer
using the form above and details about
the originator that you can populate with data from your KYC database.
Note that if the VASP corresponding to the Travel Address is unknown, it will be automatically added to the counterparty VASP table as untrusted and the TRP message is only sent after it has been marked as trusted.
React to TRP Events
The { trpdTransactions }
subscription will emit events whenever a TRP
transaction's status changes, returning a complete TrpdTxUnion
object.
At some point, you will receive TRP approval or rejection messages from your
counterparty VASP about your inquiries through TRP. You can identify them using
the status
and type
fields on the object returned from the subscription.
In case of an approval, you can proceed by executing the transaction on the
blockchain using the beneficiary.walletAddress
field on the returned object as
a recipient address. Then, the resulting transaction ID needs to be submitted to
the { trpd { confirmTx } }
mutation to finalise the TRP protocol flow.
In case of a rejection, there's no further steps required for TRP. However, you
should notify your user about the declined transaction. Maybe the counterparty
VASP has provided a reason in the comment
field.