eth_getBalance

Retrieves the balance of the specified Ethereum address.

Example

import { getRpcClient, eth_getBalance } from "thirdweb/rpc";
const rpcRequest = getRpcClient({ client, chain });
const balance = await eth_getBalance(rpcRequest, {
address: "0x...",
});
function eth_getBalance(
request: EIP1193RequestFn<
[
{
Method: "web3_clientVersion";
Parameters?: undefined;
ReturnType: string;
},
{
Method: "web3_sha3";
Parameters: [data: `0x${string}`];
ReturnType: string;
},
{
Method: "net_listening";
Parameters?: undefined;
ReturnType: boolean;
},
{
Method: "net_peerCount";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
{
Method: "net_version";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
]
>,
): Promise<bigint>;

Parameters

The EIP1193 request function.

Type

let request: EIP1193RequestFn<
[
{
Method: "web3_clientVersion";
Parameters?: undefined;
ReturnType: string;
},
{
Method: "web3_sha3";
Parameters: [data: `0x${string}`];
ReturnType: string;
},
{
Method: "net_listening";
Parameters?: undefined;
ReturnType: boolean;
},
{
Method: "net_peerCount";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
{
Method: "net_version";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
]
>;

The parameters for retrieving the balance.

Type

let params: { address: string };

Returns

let returnType: Promise<bigint>;

A promise that resolves to the balance of the address in wei as bigint.