Network
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
Parameter | Type | Description |
---|---|---|
name | string | The network name. |
chainId | BigNumberish | The network chain ID. |
Returns
Source
Accessors
chainId
The network chain ID.
Sets the network chain ID.
Parameters
Parameter | Type | Description |
---|---|---|
value | BigNumberish | The new network chain ID. |
Returns
bigint
The network chain ID.
Source
name
The network common name.
This is the canonical name, as networks might have multiple names.
Sets the network name.
Parameters
Parameter | Type | Description |
---|---|---|
value | string | The new network name. |
Returns
string
The network name.
Source
Methods
clone()
Create a copy of this Network.
Returns
A new Network instance.
Source
toJSON()
Returns a JSON-compatible representation of a Network.
Returns
any
The JSON representation of the network.
Source
from()
Returns a new Network for the network
name or chainId.
Parameters
Parameter | Type | Description |
---|---|---|
network ? | Networkish | The network to get. |
Returns
The Network instance.
Throws
If the network is invalid.
Source
register()
Register nameOrChainId
with a function which returns an instance of a Network representing that chain.
Parameters
Parameter | Type | Description |
---|---|---|
nameOrChainId | string | number | bigint | The name or chain ID to register. |
networkFunc | () => Network | The function to create the Network. |
Returns
void
Throws
If a network is already registered for nameOrChainId
.
Source
Was this page helpful?