Only available from SDK V1

Summary

This hook can be used to trigger an Onramp UI so that users can immediately buy crypto with fiat.

How it works

After setting up your onramp provider, you can use the useFunding to prompt your user to fund their wallet.

UseFunding exposes the following attributes:

MethodTypeDescription
enabledbooleanWeather funding is enable and ready to use
openFundingfunctionTrigger the onramp UI with optional address and token attributes, returns a Promise that will resolve once the onramp UI is closed

Examples

Example on a custom onramp button.

import { useFunding } from "@dynamic-labs/sdk-react-core";

const FundMyWalletButton = () => {
  const { enabled, openFunding } = useFunding();

  const onClick = () => {
    openFunding({
      token: "USDT",
      address: "0x1234567890123456789012345678901234567890",
    }).then(() => window.alert("Success!"));
  };

  return (
    <button onClick={onClick} disabled={!enabled}>
      Buy USDT
    </button>
  );
};