When creating a quote for crypto withdrawals, certain requirements may need to be resolved upfront. This flow guides you through detecting and resolving quote requirements before the transaction can be created.
Prerequisites
- A quote returned with a non-empty
requirements array
- Understanding of the transaction type you’re creating (withdrawal, transfer, etc.)
- Your application is set up to handle the Travel Rule widget (for
travel-rule requirements)
Check for requirements
When the quote is returned, check the requirements array for any requirements that need to be resolved.
{
"quote": {
"id": "623000c8-9bdf-4a2b-aa3d-6a6b44a7f6a0",
"origin": { ... },
"destination": { ... },
"denomination": { ... },
"fees": [],
"requirements": [
"travel-rule"
],
"expiresAt": "2024-07-24T15:22:39Z"
}
}
Travel Rule
Travel Rule is a regulatory requirement that mandates the collection and transmission of information about the originator and beneficiary of certain crypto transactions.
The flow
When a travel-rule requirement is present, create a widget session using Create Session endpoint.
POST /widgets/travel-rule/sessions
{
"flow": "withdrawal-form",
"data": {
"quoteId": "623000c8-9bdf-4a2b-aa3d-6a6b44a7f6a0"
}
}
A successful response includes a url and token for the widget session, and data containing additional context to setup and prefill the Travel Rule form.
{
"session": {
"flow": "withdrawal-form",
"url": "https://widgets.uphold.com/travel-rule/sessions/abc123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"data": {
"provider": "notabene",
"parameters": {
// additional context to setup and prefill the form
}
}
}
}
Launch the widget to guide the user through the Travel Rule information collection process.
The example code below is for web applications. For native applications using a WebView, you’ll still need to implement communication through a bridge to send events to the native side. Check out the Native App Integration page for more details.
import { TravelRuleWidget } from '@uphold/enterprise-travel-rule-widget-web-sdk';
// 1. Create Travel Rule widget instance
const widget = new TravelRuleWidget<'withdrawal-form'>(session, { debug: true });
// 2. Listen to relevant events
widget.on('complete', (event) => {
const { value: travelRule } = event.detail;
// Send travelRule data to your backend to create the transaction
widget.unmount();
});
widget.on('cancel', error => ...);
widget.on('error', error => ...);
// 3. Select the container element
const container = document.getElementById('tr-withdrawal');
// 4. Mount the withdrawal form widget
widget.mountIframe(container);
Check out Widgets > Travel Rule documentation for more details.
Create the transaction
Once the widget emits the complete event, create the transaction using Create Transaction endpoint.
The original quote may have expired while the user was completing the Travel Rule form. If the quote has expired, you’ll need to create a new quote before proceeding with the transaction creation. The Travel Rule data obtained from the widget remains valid and will automatically apply to the new quote.
POST /core/transactions
{
"quoteId": "623000c8-9bdf-4a2b-aa3d-6a6b44a7f6a0",
"params": {
"travelRule": {
// Travel Rule data from complete event
}
}
}
The travel-rule requirement has been successfully resolved and the transaction has been created.
This flow is used as part of: