Module
Balance — 1–5 credits
Query native currency and ERC-20 token balances for one or many addresses. Single queries cost 1 credit; batch queries cost 5 credits.
API Key or JWT
getNative()
GET
1 credit
Get the native currency balance (ETH, MATIC, BNB, etc.) for a single address.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$address | string | Yes | EVM wallet address (0x-prefixed) |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
$result = Web3Api::balance()->getNative(
address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
network: 'polygon',
);
Response
[
'address' => '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'balance' => '1.5', // string — human-readable (not wei)
'symbol' => 'MATIC',
'network' => 'polygon',
]
getToken()
GET
1 credit
API Key
Get the ERC-20 token balance for a user address. Requires API Key authentication.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$tokenAddress | string | Yes | ERC-20 contract address |
$userAddress | string | Yes | Wallet address to check balance for |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
// USDC balance on Polygon
$result = Web3Api::balance()->getToken(
tokenAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', // USDC on Polygon
userAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
network: 'polygon',
);
Response
[
'token_address' => '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
'user_address' => '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'balance' => '100.0', // human-readable
'symbol' => 'USDC',
'decimals' => 6,
]
batch()
POST
5 credits
Get native currency balances for multiple addresses in a single API call. Costs 5 credits regardless of the number of addresses.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$addresses | string[] | Yes | Array of EVM wallet addresses |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
$balances = Web3Api::balance()->batch(
addresses: [
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
'0x1db3439a222c519ab44bb1144fc28167b4fa6ee6',
],
network: 'polygon',
);
// Returns a map of address => balance string
// $balances['0xd8dA...'] => "1.5"
// $balances['0xAb58...'] => "0.25"
// $balances['0x1db3...'] => "42.0"
Response
{
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045": "1.5",
"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B": "0.25",
"0x1db3439a222c519ab44bb1144fc28167b4fa6ee6": "42.0"
}
batchToken()
POST
5 credits
Get ERC-20 token balances for multiple addresses in a single API call. All addresses are checked for the same token contract.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$tokenAddress | string | Yes | ERC-20 contract address |
$addresses | string[] | Yes | Array of wallet addresses to check |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
$balances = Web3Api::balance()->batchToken(
tokenAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', // USDC
addresses: [
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
],
network: 'polygon',
);
// $balances['0xd8dA...'] => "100.0"
// $balances['0xAb58...'] => "50.5"
Response
{
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045": "100.0",
"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B": "50.5"
}