try_native_balance

Returns an address's native-token balance as exact Wei at an explicit block, as native_balance does. A balance read cannot revert, so a failed read raises here too.

Scalar function RPC

Example

Live RPC

-- vitalik.eth at block 4200000
SELECT try_native_balance(
    $client,
    '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'::address, -- vitalik.eth
    4200000
) AS balance;

API reference

try_native_balance(CLIENT, ADDRESS, BIGINT) # RPC required

As native_balance at an explicit block height; an RPC error raises.

Inputs

Name Type Use
client CLIENT

Readable EVM state represented by a live, pinned, or execution CLIENT.

required positional
address ADDRESS

Account or contract address whose native balance should be read.

required positional
block_number BIGINT

Optional historical block height; NULL gives NULL without an RPC call.

required positional

Returns

Name Type
balance UINT256

Native balance in Wei. Returns a UINT256 raw Wei balance; NULL only for a NULL input.