Thin convenience layer for wallet-level queries.
Does
- Classify addresses as EOA or contract (
classify/2) - Fetch native ETH balance (
balance/2)
Does Not
- Track token balances (see
Onchain.ERC20) - Manage keys or signing (see
Onchain.Signer) - Parse transactions or receipts (see
Onchain.RPC)
Functions
| Function | Purpose |
|---|---|
classify/2 | Determine if address is :eoa or :contract |
classify!/2 | Same, raises on error |
balance/2 | Native ETH balance in wei |
balance!/2 | Same, raises on error |
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
balance! | 2 | Get the native ETH balance of an address in wei. Raises on error. | address: value, opts: value |
balance | 2 | Get the native ETH balance of an address in wei. | address: value, opts: value |
classify! | 2 | Classify an address as EOA or contract. Raises on error. | address: value, opts: value |
classify | 2 | Classify an address as EOA or contract. | address: value, opts: value |
Summary
Functions
Get the native ETH balance of an address in wei.
Get the native ETH balance of an address in wei. Raises on error.
Classify an address as EOA or contract.
Classify an address as EOA or contract. Raises on error.
Functions
@spec balance( String.t() | binary(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Get the native ETH balance of an address in wei.
Parameters
address- Account address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Balance in wei ({:ok, non_neg_integer} | {:error, term})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
address: %{
description: "Account address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer} | {:error, term}",
description: "Balance in wei"
}
}
@spec balance!( String.t() | binary(), keyword() ) :: non_neg_integer()
Get the native ETH balance of an address in wei. Raises on error.
Parameters
address- Account address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Balance in wei (non_neg_integer)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
address: %{
description: "Account address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{type: :non_neg_integer, description: "Balance in wei"}
}
Classify an address as EOA or contract.
Parameters
address- Account address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
:eoa if no bytecode, :contract if bytecode exists ({:ok, :eoa | :contract} | {:error, term})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
address: %{
description: "Account address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, :eoa | :contract} | {:error, term}",
description: ":eoa if no bytecode, :contract if bytecode exists"
}
}
Classify an address as EOA or contract. Raises on error.
Parameters
address- Account address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Address type atom (:eoa | :contract)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
address: %{
description: "Account address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{type: ":eoa | :contract", description: "Address type atom"}
}