Skip to content
docs

NetworksTable

Defined in: table.ts:84

The wallet’s networks and their endpoints: the shipped catalog and testnets plus what the user and sites added. Storage holds only the changes, so app updates with new endpoints reach every install. Call load() once at start; the …Sync readers answer from memory after that.

new NetworksTable(storage, builtins?): NetworksTable

Defined in: table.ts:90

JsonStorage<NetworksState>

readonly Network[] = BUILTIN_NETWORKS

NetworksTable

readonly builtins: readonly Network[] = BUILTIN_NETWORKS

Defined in: table.ts:90

get loaded(): boolean

Defined in: table.ts:98

Whether load() has completed — before that listSync / getSync answer builtin-only and the sync endpoint readers throw.

boolean

add(network): Promise<void>

Defined in: table.ts:188

Add a custom network. Refused for a builtin caip2 (prepend RPCs with addRpc instead) and for RPCs outside the URL policy.

Network

Promise<void>


addRpc(caip2, url): Promise<void>

Defined in: table.ts:226

Add a user RPC after the existing user RPCs, before the shipped list. Check it with checkRpcUrl and verifyNetwork first.

string

string

Promise<void>

NetworkError unknown-network, or url-policy for a URL the policy refuses.


allowHttpLocal(): Promise<boolean>

Defined in: table.ts:170

Whether http:// RPCs on private addresses are accepted.

Promise<boolean>


allowHttpLocalSync(): boolean

Defined in: table.ts:175

Same as allowHttpLocal() from memory.

boolean


enable(caip2, enabled): Promise<void>

Defined in: table.ts:249

Switch a network on or off (testnets ship off).

string

boolean

Promise<void>


get(caip2): Promise<NetworkEntry | null>

Defined in: table.ts:126

One network, or null when unknown.

string

Promise<NetworkEntry | null>


getSync(caip2): NetworkEntry | null

Defined in: table.ts:131

Same as get() from memory.

string

NetworkEntry | null


list(): Promise<NetworkEntry[]>

Defined in: table.ts:115

Every network with its effective endpoints and issues.

Promise<NetworkEntry[]>


listSync(): NetworkEntry[]

Defined in: table.ts:121

Same as list() from memory; builtin table only before load().

NetworkEntry[]


load(): Promise<void>

Defined in: table.ts:93

Read the stored state once; later calls answer from memory. Safe to call many times.

Promise<void>


markRpc(caip2, url, result, now?): Promise<void>

Defined in: table.ts:264

Record a verification result for one user RPC: a failure parks the URL (with the reason), a pass clears it.

string

string

VerifyResult

number = ...

Promise<void>


remove(caip2): Promise<void>

Defined in: table.ts:205

Remove a custom network. Builtins cannot be removed (disable them instead).

string

Promise<void>


removeRpc(caip2, url): Promise<void>

Defined in: table.ts:240

Remove a user RPC.

string

string

Promise<void>

NetworkError unknown-network, or last-rpc for the last RPC of a custom network.


reset(): Promise<void>

Defined in: table.ts:274

Forget everything the user changed.

Promise<void>


rpcUrlsFor(caip2): Promise<string[]>

Defined in: table.ts:136

Endpoints to try, in order: healthy user RPCs, then the builtin list unless onlyOwnRpc. Empty for an unknown network.

string

Promise<string[]>


rpcUrlsForSync(caip2): string[]

Defined in: table.ts:146

rpcUrlsFor from memory — what a sync consumer (a viem client factory) reads. Throws NetworkError('not-loaded') before load(): the builtin list would ignore the user’s own RPCs and their onlyOwnRpc choice.

string

string[]


setAllowHttpLocal(v): Promise<void>

Defined in: table.ts:183

Turn the http:// on private addresses setting on or off.

boolean

Promise<void>


setBalancesViaOwnRpc(caip2, balancesViaOwnRpc): Promise<void>

Defined in: table.ts:259

Read balances over the user’s RPC instead of the app’s server.

string

boolean

Promise<void>


setOnlyOwnRpc(caip2, onlyOwnRpc): Promise<void>

Defined in: table.ts:254

Use only the user’s RPCs for this network, dropping the shipped fallback.

string

boolean

Promise<void>


setRpcs(caip2, rpcs): Promise<void>

Defined in: table.ts:216

Replace the user’s RPC list for a network (prepended to the builtin list; the whole list for a custom network).

string

readonly string[]

Promise<void>


subscribe(fn): () => void

Defined in: table.ts:107

Fires after every write (UI refresh).

() => void

() => void


usesUserRpc(caip2): Promise<boolean>

Defined in: table.ts:164

Same as usesUserRpcSync(), after loading.

string

Promise<boolean>


usesUserRpcSync(caip2): boolean

Defined in: table.ts:156

Whether the first endpoint a consumer will use is user- or site-supplied (→ “Custom RPC — simulation not trusted”). Throws before load().

string

boolean