Hethers
Search…
Providers
A Provider is an abstraction of a connection to the Hedera Hashgraph network, providing a concise, consistent interface to standard Hedera Hashgraph consensus node and mirror nodes functionality.
The hethers.js library provides several options which should cover the vast majority of use-cases but also includes the necessary functions and classes for sub-classing if a more custom configuration is necessary.
Most users should use the Default Provider.

Default Provider

The default provider is the safest, easiest way to begin developing on Hedera Hashgraph, and it is also robust enough for use in production. It creates a DefaultHederaProvider connection to a Hedera backend service.

hethers.getDefaultProvider( [ network , [ options ] ] ) ⇒ Provider

Returns a new Provider, backed by multiple services (Hedera Consensus Nodes and Mirror Nodes), connected to the network. If no network is provided, mainnet is used.
The network may also be a URL to connect to, such as http://localhost:50211
It is highly recommended for production services to acquire unthrottled access to Mirror Node.

Options

The provider class uses axios under the hood. Users can override the headers through the provider's options parameter.
const options = { headers: {testHeader: '123'} };
hethers.providers.getDefaultProvider('testnet', options);
Note: Only the headers part will be propagated to Axios

Networks

There are several official common Hedera networks (as well as custom networks and other compatible projects).
Any API that accepts a Networkish can be passed a common name (such as "mainnet" or "previewnet") or chain ID to use that network definition or may specify custom parameters.

hethers.providers.getNetwork(aNetworkish) ⇒ Network

Returns the full Network for the given standard aNetworkish Networkish.
This is useful for functions and classes which wish to accept Networkish as an input parameter.
// By Chain Name
getNetwork("mainnet");
// {
// chainId: 290,
// ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
// name: 'mainnet'
// }
// By Chain ID
getNetwork(290);
// {
// chainId: 290,
// ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
// name: 'mainnet'
// }
Copy link