fetchOnrampConfig
The fetchOnrampConfig
utility fetches the list of countries supported by Coinbase Onramp and their available payment methods. This is useful when you need to validate user eligibility or display available payment options.
Usage
code
import { fetchOnrampConfig } from '@coinbase/onchainkit/fund';
// When using with OnchainKitProvider
const config = await fetchOnrampConfig();
// When using without OnchainKitProvider or in non-React environment
const config2 = await fetchOnrampConfig('your-api-key');
Parameters
/**
* Optional API key for Coinbase Onramp. If not provided, the API key from
* OnchainKitProvider will be used. Required when using the utility without
* OnchainKitProvider or in a non-React environment.
*/
apiKey?: string;
Returns
Promise<OnrampConfigResponseData>
- Returns a promise that resolves to the configuration data containing supported countries and their payment methods.
See OnrampConfigResponseData
for response type details.