---
url: /docs/stablecoin/payout-stellar.md
description: >-
  Fund a payout from an external Stellar wallet, authorize the payout, sign the
  XDR transaction, then create the payout.
---

This tutorial funds a [payout](/stablecoin/payouts) from an external [blockchain wallet](/stablecoin/blockchain-wallets) on Stellar. Stellar has no allowance mechanism, so the client constructs and signs a real payment transaction to BlindPay's treasury address: authorize, sign, then create the payout.

BlindPay's Stellar mainnet treasury address: `GCOSSQDM2SWMHRP7CDBOLL2V45NHCRLUWUCEHPPBA2ABCOOLPOLZKIHE`. This is the address that receives payout crypto and sends payin crypto on Stellar mainnet.

The examples below use `stellar_testnet` and `USDB` since they're the development network and test token. Swap in the production network and token (`USDC`) when you go live.

## Prerequisites

You also need a [customer](/learn/customers) with `kyc_status: "approved"`, a [bank account](/stablecoin/bank-accounts) (`ba_...`), and an unexpired [payout quote](/stablecoin/payout-quotes) (`qu_...`) created with a Stellar `network`.

### Authorize the payout

Call the authorize endpoint with the quote and the sender's wallet address. This does not consume the quote or create any record, it only returns an unsigned transaction hash for the client to sign.

```bash [cURL]
curl --request POST \
  --url https://api.blindpay.com/v1/instances/in_000000000000/payouts/stellar/authorize \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "quote_id": "qu_000000000000",
  "sender_wallet_address": "YOUR_WALLET_ADDRESS"
}'
```

The response is the unsigned transaction, ready to sign:

```json
{
  "transaction_hash": "AAA...AAA"
}
```

### Sign and submit the transaction

Install the Stellar SDK:

```bash
npm install @stellar/stellar-sdk
```

Sign the returned transaction with the sender's Stellar key and submit it to the network:

```js [index.js]
import {
  Horizon,
  Keypair,
  Networks,
  TransactionBuilder,
} from '@stellar/stellar-sdk'

const server = new Horizon.Server('https://horizon-testnet.stellar.org')
const sourceKeypair = Keypair.fromSecret(process.env.STELLAR_SECRET_KEY)

// Rebuild the transaction returned by the authorize endpoint
const transaction = TransactionBuilder.fromXDR(
  transactionHash,
  Networks.TESTNET
)

// Sign it with the sender's key
transaction.sign(sourceKeypair)

// Submit it to Stellar
const result = await server.submitTransaction(transaction)

console.log(result.hash)
// Save result.hash, you need it to create the payout on BlindPay
```

### Create the payout

Create the payout with the quote, the sender's wallet address, and the signed transaction from the previous step. BlindPay independently re-validates the signed transaction against the quote (destination and amount) before dispatching the payout.

```bash [cURL]
curl --request POST \
  --url https://api.blindpay.com/v1/instances/in_000000000000/payouts/stellar \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "quote_id": "qu_000000000000",
  "signed_transaction": "YOUR_SIGNED_TRANSACTION",
  "sender_wallet_address": "YOUR_WALLET_ADDRESS"
}'
```

That's a completed payout on Stellar. To send another, create a new quote and repeat the authorize, sign, and create steps, the quote and signed transaction are single-use.

## Related

* [Payouts](/stablecoin/payouts): status lifecycle, cover\_fees, testing sentinels, and webhooks
* [Payout quotes](/stablecoin/payout-quotes): full request and response fields
* [Mint USDB](/stablecoin/mint-usdb): mint on Stellar Testnet, including the one-time trustline
* [Payout with managed wallet](/stablecoin/payout-managed-wallet): the no-signing alternative (Stellar not yet supported for managed wallets)
