Class: Onramper
gSwap SDK 2.0.0-rc.4 / Onramper
Class: Onramper
Defined in: packages/gswap-sdk/dist/index.d.ts:2269
The swap backend's Onramper (fiat on-ramp) widget URL. The route is PUBLIC: the request carries
no Authorization header and no signature, whatever session the app has, so no token can leak to
it. The backend signs the wallet into the URL; the app adds its own look (theme query parameters)
to the returned URL.
Constructors
Constructor
new Onramper(
dexBackendBaseUrl,httpClient):Onramper
Defined in: packages/gswap-sdk/dist/index.d.ts:2281
Creates the service. To get one without building a whole GSwap client, use createOnramper.
Parameters
dexBackendBaseUrl
string
httpClient
HttpClient
Returns
Onramper
Example
const onramper = new Onramper('https://dex-backend-prod1.defi.gala.com', httpClient);
Methods
generateWidgetUrl()
generateWidgetUrl(
request):Promise<string>
Defined in: packages/gswap-sdk/dist/index.d.ts:2304
Asks the backend for a signed Onramper widget URL for request.walletAddress.
Parameters
request
Returns
Promise<string>
The widget URL.
Throws
GSwapSDKError INVALID_DTO (before anything is sent: no wallet address, an unknown
mode, a text field that is not text, an amount that is not a finite number of 0 or more),
HTTP_ERROR (the backend refused: serverMessage is its message, e.g. "Failed to generate
widget URL. Check server configuration." for a 500, its validation message for a 400, the
throttle for a 429), REQUEST_FAILED (no answer), INVALID_CHAIN_RESPONSE (an answer without
a usable data.url).
Example
const url = await gSwap.onramper.generateWidgetUrl({
walletAddress: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
defaultCrypto: 'gala',
onlyCryptoNetworks: 'gala',
mode: 'buy',
});
window.open(url);