跳转到主要内容
注意: 此页面尚未翻译成中文。以下内容为英文原版。
A Network provides access to a chain’s properties and allows for plug-ins to extend functionality.

Constructors

new 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

The network chain ID.
Sets the network chain ID.

Parameters

ParameterTypeDescription
valueBigNumberishThe new network chain ID.

Returns

bigint The network chain ID.

Source

providers/network.ts:87

name

The network common name. This is the canonical name, as networks might have multiple names.
Sets the network name.

Parameters

ParameterTypeDescription
valuestringThe new network name.

Returns

string The network name.

Source

providers/network.ts:69

Methods

clone()

Create a copy of this Network.

Returns

Network A new Network instance.

Source

providers/network.ts:153

toJSON()

Returns a JSON-compatible representation of a Network.

Returns

any The JSON representation of the network.

Source

providers/network.ts:58

from()

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()

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