Inside FxAeon, product reads use getFxReadFacade(). The underlying Ethereum SDK is a shared instance; route components should not construct another instance or import getFxSdk for reads.
import { formatUnits, type Address } from 'viem';
import { getFxReadFacade } from '@/lib/fx/readFacade';
// Inside the FxAeon mini-app. No wallet signature is requested.
export async function readFxSaveBalance(userAddress: Address) {
const { balanceWei, assetsWei } = await getFxReadFacade()
.getFxSaveBalance({ userAddress });
return {
fxSaveShares: formatUnits(balanceWei, 18),
basePoolShares: assetsWei !== undefined
? formatUnits(assetsWei, 18)
: balanceWei === 0n ? '0' : null,
};
}This example uses the mini-app's @/ import alias. Call it with the wallet address you want to read. Errors remain errors; catch them in your UI and show unavailable or stale state. null means a nonzero balance has no asset conversion available, not zero assets.
For a separate project, install @aladdindao/[email protected]. The following uses only the public constructor and read API available in that version. It does not include FxAeon's patches, deadlines, or execution safeguards.
import { FxSdk } from '@aladdindao/fx-sdk';
// Initialize once, before other SDK consumers in this process.
const sdk = new FxSdk({
chainId: 1,
rpcUrl: 'https://ethereum-rpc.publicnode.com',
});
export async function readFxSaveSupply() {
const config = await sdk.getFxSaveConfig();
return {
fxSaveSharesWei: config.totalSupplyWei.toString(),
basePoolSharesWei: config.totalAssetsWei.toString(),
cooldownSeconds: config.cooldownPeriodSeconds.toString(),
};
}The RPC must serve Ethereum. SDK 1.0.5 shares an internal RPC singleton, so the first configuration wins. FxAeon keeps its canonical Ethereum instance separate from the source-chain transport supplied to bridge requests. A successful read is a snapshot, not a guarantee that a later transaction will succeed.
Sources: SDK adapter (opens in a new tab), read facade (opens in a new tab), fxSAVE units (opens in a new tab).