Skip to content

Sell widget: events

The sell widget emits events that your application can listen to. Use the native window.addEventListener to handle them:

window.addEventListener('EVENT_NAME', (event) => {
// The data sent by the widget is in event.detail
});

Replace EVENT_NAME with the event names described below.

When a user confirms his order in the order form, the widget provides the order details so that an actual transaction on the chain can be created.

Event name: btcdirect-embeddable-coin-to-fiat-order-requested

// event.detail:
{
currency: 'BTC', // The cryptocurrency ticker
amount : 0.1, // The crypto amount that will be sold
orderId: 123456, // The ID of the order
}

If you’ve provided wallet addresses to the widget, as mentioned in Provide wallet address(es), the necessary information will be part of the event:

// event.detail:
{
currency: 'BTC', // The cryptocurrency ticker
amount : 0.1, // The crypto amount that will be sold
walletAddress: 'abc12', // The address to send the coins to
destinationTag: '123456', // Optional destination tag (only for XRP orders)
orderId: 123456, // The ID of the order
userWalletAddress: 'def34'; // The wallet address of the user
}