๐ธ Fiat Support Comes to ChainGate library
ยท One min read
You asked for it โ and it's here.
Fiat currency support is now fully integrated into the ChainGate SDK.
Previously, fiat pricing was only available through the /global/markets
API. Now, you can use fiat values directly within your wallet logic, including balance display, transfers, and conversions โ all using simple, familiar fiat codes like usd
, eur
, gbp
, and more.
What this means for developersโ
With fiat support in the SDK, you can now:
- ๐ฐ Convert on-chain balances to real-time fiat equivalents with
.toFiat('usd')
. - ๐ธ Send fiat-denominated amounts using
currency.amountFiat('25', 'eur')
. - ๐ง Create intuitive UIs where users input fiat but transact in crypto behind the scenes.
- ๐ Stay accurate and up-to-date thanks to built-in exchange rate lookups.
Example: Display balance in fiatโ
const ethereum = wallet.currency('ethereum')
const balance = await ethereum.getBalance()
console.log('Confirmed:', balance.confirmed.str)
// e.g., "0.0048 eth"
const amountInEur = await balance.confirmed.toFiat('eur')
console.log('In EUR:', amountInEur.toString())
// e.g., "16.73"