convertFiatToCrypto

Convert a fiat value to a token. Currently only USD is supported.

Example

Basic usage

import { convertFiatToCrypto } from "thirdweb/pay";
// Convert 2 cents to ETH
const result = await convertFiatToCrypto({
from: "USD",
// the token address. For native token, use NATIVE_TOKEN_ADDRESS
to: "0x...",
// the chain (of the chain where the token belong to)
chain: ethereum,
// 2 cents
fromAmount: 0.02,
});

Result: { result: 0.0000057 }

function convertFiatToCrypto(
): Promise<{ result: number }>;

Parameters

Type

let options: {
chain: Chain;
client: ThirdwebClient;
from: SupportedFiatCurrency;
fromAmount: number;
to: Address;
};

Returns

let returnType: Promise<{ result: number }>;