A Network provides access to a chain’s properties and allows for plug-ins to extend functionality.

Constructors

new Network()

new Network(name, chainId): Network

Creates a new Network for name and chainId.

Parameters

ParameterTypeDescription
namestringThe network name.
chainIdBigNumberishThe network chain ID.

Returns

Network

Source

providers/network.ts:48

Accessors

chainId

get chainId(): bigint

The network chain ID.

set chainId(value): void

Sets the network chain ID.

Parameters

ParameterTypeDescription
valueBigNumberishThe new network chain ID.

Returns

bigint

The network chain ID.

Source

providers/network.ts:87


name

get name(): string

The network common name.

This is the canonical name, as networks might have multiple names.

set name(value): void

Sets the network name.

Parameters

ParameterTypeDescription
valuestringThe new network name.

Returns

string

The network name.

Source

providers/network.ts:69

Methods

clone()

clone(): Network

Create a copy of this Network.

Returns

Network

A new Network instance.

Source

providers/network.ts:153


toJSON()

toJSON(): any

Returns a JSON-compatible representation of a Network.

Returns

any

The JSON representation of the network.

Source

providers/network.ts:58


from()

static from(network?): Network

Returns a new Network for the network name or chainId.

Parameters

ParameterTypeDescription
network?NetworkishThe network to get.

Returns

Network

The Network instance.

Throws

If the network is invalid.

Source

providers/network.ts:165


register()

static register(nameOrChainId, networkFunc): void

Register nameOrChainId with a function which returns an instance of a Network representing that chain.

Parameters

ParameterTypeDescription
nameOrChainIdstring | number | bigintThe name or chain ID to register.
networkFunc() => NetworkThe function to create the Network.

Returns

void

Throws

If a network is already registered for nameOrChainId.

Source

providers/network.ts:217