auradefi 0.1.1
PyPI GitHub

EtherscanV2

auradefi.sources.evm.etherscan · source

Etherscan V2 balance source over an injected httpx.Client.

The client is REQUIRED and injected so cassettes plug in; the constructor performs no I/O. api_key=None omits the apikey query param entirely.

__init__

__init__(self, client: httpx.Client, api_key: str | None = None, base_url: str = https://api.etherscan.io/v2/api, page_size: int = 1000) -> None

Bind the injected client and request parameters. No I/O.

Parameters

clientrequired, httpx.Client

none

api_keyoptional, str | None, default None

none

base_urloptional, str, default 'https://api.etherscan.io/v2/api'

none

page_sizeoptional, int, default 1000

none

balances

balances(self, chain_id: str, address: str) -> list[BalanceRecord]

All non-zero balances for address on chain_id.

chain_id is CAIP-2: the namespace must be "eip155" with a base-10 integer reference, else ValidationError is raised BEFORE any HTTP. The input address is lowercased before use.

Envelope {status, message, result}: status "1" is success; status "0" with message "No transactions found" is an EMPTY discovery result, not an error; any other status "0", any non-2xx HTTP, and any malformed body raise SourceError (auradefi.errors).

Records with quantity.raw == 0 are omitted (native included only when non-zero). Return order: native first, then tokens ascending by lowercased contract address.

Parameters

chain_idrequired, str

none

addressrequired, str

none

Raises

SourceError, ValidationError