Skip to main content

Receive USD onchain

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 New Address to Receive USD

Using Stablesats a merchant can generate and onchain address where the bitcoin received will be denominated in USD cents.
Use the address from the response and send to it from any bitcoin wallet.
The received satoshi amount will reflect the USD/BTC exchange rate at the time it was received and the balance will be kept at the dollar value.

The body of the GraphQL request

mutation onChainAddressCreate($input: OnChainAddressCreateInput!) {
onChainAddressCreate(input: $input) {
address
errors {
message
}
}
}
Set the USD wallet ID:
curl command to generate a new address

Once Paid Check the Balance Again

The balance will be updated once the transaction is confirmed on the blockchain.
Until the confirmation the new incoming amount will show in the pendingIncomingBalance field.

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 including pendingIncomingBalance

query Me {
me {
defaultAccount {
wallets {
walletCurrency
balance
pendingIncomingBalance
}
}
}
}
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.