Skip to main content

Receive USD on Lightning

The GraphQL endpoint to connect to:
A valid authentication token is required in the header as a bearer token:

Get the wallet IDs and check the balances

Can run this query at any stage to confirm the change in the balances.
The "BTC" wallet balance is denominated in satoshis.
The "USD" wallet balance is in cents.

The body of the GraphQL request

query Me {
me {
defaultAccount {
wallets {
id
walletCurrency
balance
}
}
}
}
curl command to get the USD wallet ID

Generate a Stablesats invoice

Using Stablesats a merchant can generate invoices denominated in USD cents.
Use the paymentRequest from the response and pay it with a lightning wallet.
The satoshi amount of the invoice will reflect the current USD/BTC exchange rate and the balance will be kept at the dollar value.

The body of the GraphQL request

mutation LnUsdInvoiceCreateOnBehalfOfRecipient($input: LnUsdInvoiceCreateOnBehalfOfRecipientInput!) {
lnUsdInvoiceCreateOnBehalfOfRecipient(input: $input) {
invoice {
paymentRequest
paymentHash
paymentSecret
satoshis
}
errors {
message
}
}
}
Set the variables
curl command to generate a Stablesats invoice

Once paid check the balance again

tip

There are multiple ways to get notified on the incoming payments: see how to use webhooks (callbacks) and websocket subscriptions.

The body of the GraphQL request to check the balance

query Me {
me {
defaultAccount {
wallets {
walletCurrency
balance
}
}
}
}
curl command to check the balance of your wallets
tip

To test the GraphQL requests further use the GraphQL playground at api.blink.sv/graphql for mainnet or api.staging.blink.sv/graphql for staging.
Check out the Galoy API Postman collection to find examples in multiple programming languages.