getBalance
Get the balance of the given account, identified by its address.
Usage
example.ts
import { publicClient } from "./client";
const balance = await publicClient.getBalance({
address: "cfx:...",
});
Returns
bigint
The balance of the address in drip.
Parameters
address
- Type
Address
The address to check for balance
const balance = await publicClient.getBalance({
address: "cfx:...",
});
epochTag (optional)
- Type:
latest_state
|latest_confirmed
|latest_checkpoint
|earliest
- Defaut:
latest_state
const balance = await publicClient.getBalance({
address: "cfx:...",
epochTag: "latest_state",
});
epochNumber (optional)
- Type:
bigint
const balance = await publicClient.getBalance({
address: "cfx:...",
epochNumber: 1n,
});
Tips
You can convert the balance to ether units with formatCFX
.
import { formatCFX } from "cive";
const balance = await publicClient.getBalance({
address: "cfx:...",
});
const balanceAsCFX = formatCFX(balance);
// "99"