Library Configuration
This page details how to configure the libraries for domain resolution.
Resolution libraries require a connection to the Ethereum network to resolve .crypto and .eth domains. To initialize the library, you need to specify an Ethereum node service provider. Once the instance is created you can begin resolving domains. Below are examples of how to initialize the library with different providers.
Each of the resolution libraries supports an Ethereum provider url for configuration. You can obtain a provider url from a service like Alchemy where obtaining an API key is free and only requires creating an account.
To choose an alternative Ethereum provider see Nodes as a Service guide.
Unstoppable libraries use Alchemy provider by default without restrictions and rate limits for UNS resolution. Default configuration can be considered as production-ready.
For ENS (.eth) resolution it's recommended update Ethereum provider to use in production.
ENS is not supported in the latest version of our libraries, and there will be no future updates to ENS. The older version of our libraries can still be used for resolution, or developers will need to integrate directly with ENS.

JavaScript Resolution library

Configuration for the Javascript resolution library

Provider URL

1
import Resolution from "@unstoppabledomains/resolution";
2
3
const infuraApiKey = INFURA_PROJECT_ID;
4
5
const infuraProviderUrl = `https://mainnet.infura.io/v3/${infuraApiKey}`;
6
const poligonProviderUrl = `https://polygon-mainnet.infura.io/v3/${infuraApiKey}`;
7
8
const resolution = new Resolution({
9
sourceConfig: {
10
uns: {
11
locations: {
12
Layer1: {url: infuraProviderUrl, network: 'mainnet'},
13
Layer2: {
14
url: poligonProviderUrl,
15
network: 'polygon-mainnet',
16
},
17
},
18
},
19
ens: {url: infuraProviderUrl, network: 'mainnet')
20
},
21
});
22
23
24
const resolution = Resolution.infura(infuraApiKey);
Copied!

Web3 provider

Connect a web3 provider. You may already have one available in your application from wallets like Metamask and WalletConnect.
1
import Resolution from "@unstoppabledomains/resolution";
2
3
// if web3rovider is attached to window
4
const web3Provider = window.ethereum;
5
6
// if web3Provider.version - 0.x
7
const resolution = Resolution.fromWeb3Version0Provider(web3Provider);
8
// or
9
// if web3Provider.version - 1.x
10
const resolution = Resolution.fromWeb3Version1Provider(web3Provider);
Copied!

Ethers provider

Connect a provider from ethers.js
1
import Resolution from "@unstoppabledomains/resolution";
2
3
const resolution = Resolution.fromEthersProvider(ethersProvider);
Copied!

Java Resolution library

Configuration for the Java resolution library

Provider URL

1
import com.unstoppabledomains.resolution.Resolution
2
3
String infuraApiKey = INFURA_PROJECT_ID;
4
String ethProviderURL = "https://mainnet.infura.io/v3/" + infuraApiKey
5
String polygonProviderURL = "https://polygon-mainnet.infura.io/v3/" + infuraApiKey
6
7
DomainResolution resolution = Resolution.builder()
8
.unsProviderUrl(UNSLocation.Layer1, ethProviderURL)
9
.unsProviderUrl(UNSLocation.Layer1, polygonProviderURL)
10
.build();
Copied!

Swift Resolution library

Configuration for the Swift resolution library

Provider URL

1
import UnstoppableDomainsResolution
2
3
let infuraApiKey = INFURA_PROJECT_ID
4
5
guard let resolution = try? Resolution(
6
configs: Configurations(
7
uns: UnsLocations(
8
layer1: NamingServiceConfig(
9
providerUrl: "https://mainnet.infura.io/v3/" + infuraApiKey,
10
network: "mainnet"),
11
layer2: NamingServiceConfig(
12
providerUrl: "https://polygon-mainnet.infura.io/v3/" + infuraApiKey,
13
network: "polygon-mainnet")
14
)
15
)
16
) else {
17
print ("Init of Resolution instance with custom parameters failed...")
18
return
19
}
Copied!

Golang Resolution Library

Configuration for the Golang resolution library

Provider URL

1
import (
2
"github.com/unstoppabledomains/resolution-go"
3
)
4
5
var infuraApiKey = INFURA_PROJECT_ID
6
var providerURL = "https://mainnet.infura.io/v3/" + infuraApiKey
7
var unsResolution, _ = resolution.NewUnsBuilder().SetEthereumNetwork(providerURL).Build()
8
var znsResolution, _ = resolution.NewZnsBuilder().Build()
Copied!
Last modified 11d ago