The following tutorial demonstrates how to use Taxi HTTP JSON APIs to retrieve a topup tx.
Let's say, for example, that you want to transfer your USDt funds to somebody but you don't have any LBTC to pay for network fees.
You can check if Taxi supports paying for network fees in exchange for a USDt service fee.
To request a topup you need to specify the service fee asset, an approximate estimation of the size of your tx (take into account that Taxi always adds 1 input, 1 output and the fee output to it) and the sats/vByte ratio expressed in mSats/vB (
1 sats/vB = 1000 mSats/vB).
The response object returned by the HTTP JSON endpoint is like the following:
topup.topupIdis the id of the topup that Taxi uses internally to uniquely identify it.
topup.partialis the pset created by Taxi to which you can add inputs and outputs to transfer your funds. The tx contains exactly 1 LBTC input and 2 outputs. The input is entirely spent by the fee output. The maximum final tx size, or the number of inputs and outputs you can add to it, depends on the fee amount and the sats/vByte ratio you passed in the request. The second output is the service fee, that you must pay with your funds.
expiryis the unix timestamp of the expiration date for the topup. After that date, if Taxi doesn't see the topup tx included in blockchain, it takes care of creating another tx and transfer the same input to one of its addresses. Any later attempt to broadcast the topup tx fails because Taxi's input has already been spent.
assetHashis the service fee asset, exactly the one passed in the request object.
assetAmountis the service fee amount that you must pay with your own funds.
inBlindingDatais the list of unblinded data of the confidential inputs added by Taxi to the topup tx (always 1 tx input, therefore 1 entry). Includes the unblinded asset, value and relative blinders. Note that the blinders are encoded in base64 standard encoding instead of "normal" hex encoding, just because this is the standard format for the representation of raw bytes in HTTP JSON objects.
The complete version of the tutorial with instructions to run a live demo can be found on Github.