resolution

Resolution library that talks with etherium .crypto registry to resolve various information attached to .crypto domain

License

License

Categories

Categories

Doma Data ORM
GroupId

GroupId

com.unstoppabledomains.resolution
ArtifactId

ArtifactId

unstoppable-resolution
Last Version

Last Version

2.0.0u
Release Date

Release Date

Type

Type

jar
Description

Description

resolution
Resolution library that talks with etherium .crypto registry to resolve various information attached to .crypto domain
Project URL

Project URL

https://github.com/unstoppabledomains/resolution-java
Source Code Management

Source Code Management

https://github.com/unstoppabledomains/resolution-java

Download unstoppable-resolution

How to add to project

<!-- https://jarcasting.com/artifacts/com.unstoppabledomains.resolution/unstoppable-resolution/ -->
<dependency>
    <groupId>com.unstoppabledomains.resolution</groupId>
    <artifactId>unstoppable-resolution</artifactId>
    <version>2.0.0u</version>
</dependency>
// https://jarcasting.com/artifacts/com.unstoppabledomains.resolution/unstoppable-resolution/
implementation 'com.unstoppabledomains.resolution:unstoppable-resolution:2.0.0u'
// https://jarcasting.com/artifacts/com.unstoppabledomains.resolution/unstoppable-resolution/
implementation ("com.unstoppabledomains.resolution:unstoppable-resolution:2.0.0u")
'com.unstoppabledomains.resolution:unstoppable-resolution:jar:2.0.0u'
<dependency org="com.unstoppabledomains.resolution" name="unstoppable-resolution" rev="2.0.0u">
  <artifact name="unstoppable-resolution" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.unstoppabledomains.resolution', module='unstoppable-resolution', version='2.0.0u')
)
libraryDependencies += "com.unstoppabledomains.resolution" % "unstoppable-resolution" % "2.0.0u"
[com.unstoppabledomains.resolution/unstoppable-resolution "2.0.0u"]

Dependencies

compile (4)

Group / Artifact Type Version
org.bouncycastle : bcprov-jdk15on jar 1.65.01
com.fasterxml.jackson.core : jackson-databind jar 2.0.1
org.projectlombok : lombok jar 1.18.16
org.apache.commons : commons-math3 jar 3.6.1

runtime (2)

Group / Artifact Type Version
com.esaulpaugh : headlong jar 3.4.1
com.google.code.gson : gson jar 2.8.6

Project Modules

There are no modules declared in this project.

Version CI Version Unstoppable Domains Documentation Get help on Discord

Resolution-Java

Resolution-Java is a library for interacting with blockchain domain names. It can be used to retrieve payment addresses, IPFS hashes for decentralized websites, and GunDB usernames for decentralized chat.

Resolution-Java is primarily built and maintained by Unstoppable Domains.

Resoultion-Java supports decentralized domains across two zones:

  • Crypto Name Service (CNS)
    • .crypto
  • Ethereum Name Service (ENS)
    • .eth
    • .kred
    • .xyz
    • .luxe

Releases

The most recent release of this library is available on Maven Central.

Usage

This library uses linkpool as default blockchain provider for CNS & ENS and zilliqa for ZNS (Mainnet is default network for all).
If you want to use an alternative blockchain provider such as infura (or any other), you can change default settings:

// Default config: 

DomainResolution resolution = new Resolution(); 

// Optionally override default config using builder options:

DomainResolution resolution = Resolution.builder()
                .chainId(NamingServiceType.ENS, Network.ROPSTEN)
                .providerUrl(NamingServiceType.ENS, "https://ropsten-rpc.linkpool.io/")
                .build(); 

// Infura config:

DomainResolution resolution = Resolution.builder()
                .chainId(NamingServiceType.ENS, Network.ROPSTEN)
                .infura(NamingServiceType.ENS, <ProjectId>)
                .infura(NamingServiceType.CNS, Network.MAINNET, <ProjectId>)
                .build();

// Custom provider config:

DomainResolution resolution = Resolution.builder()
                .provider(new IProvider() {      
                    @Override
                    public JsonObject request(String url, JsonObject body) throws IOException {
                        // TODO Make post request to url with given body 
                        // and return JsonObject from the response
                        return null;
                    }
                })
                .build();

Live usage examples

Getting a domain's crypto address

Resolving a domain and getting a currency address.

String addr = resolution.getAddress("brad.crypto", "eth");
assertEquals("0x8aaD44321A86b170879d7A244c1e8d360c99DdA8", addr);

Getting a domain owner's Ethereum address

Each decentralized domain is owned by someone on the blockchain and held within their wallet. The following command will return the domain owner's Ethereum address.

String owner = resolution.getOwner("brad.crypto");
assertEquals("0x8aad44321a86b170879d7a244c1e8d360c99dda8", owner);

Getting a domain's IPFS hash

Decentralized websites host their content on decentralized file storage systems such as IPFS. To get the IPFS hash associated with a domain (and therefore its content), you can use the getIpfsHash method.

String ipfs = resolution.getIpfsHash("brad.crypto");
assertEquals("Qme54oEzRkgooJbCDr78vzKAWcv6DDEZqRhhDyDtzgrZP6", ipfs);

Errors

If the domain you requested is not registered or doesn't have the record you are looking for, this library will throw a NamingServiceException error with one of these codes. We recommend creating customized errors in your app based on the return value of the error.

public enum NSExceptionCode {
  UnsupportedDomain,
  UnregisteredDomain,
  UnknownCurrency,
  RecordNotFound,
  BlockchainIsDown,
  UnknownError,
  IncorrectContractAddress,
  IncorrectMethodName,
  UnspecifiedResolver;
}

Development

Build & test

Note: if you don't wish to install Gradle you can use it with wrapper: ./gradlew instead of gradle.

  • Configure a TESTING_PROVIDER_URL and TESTING_INFURA_PROJECT_ID environment variables with your blockchain provider for testing.
  • To run a build with associated tests, use gradle build.
  • To run a build without running the tests, use gradle build -x test.

Internal network config

Internal network config can be updated by running the gradle pullNetworkConfig task and committing the updated file.

Versioning & release process

On codebase updates

  • Contributors should update CHANGELOG.md with the listed changes, and increment the client version in client.json.

New packages

  • Create a new Github release (using semver);
  • Wait for a successful Github Workflow publishing;
  • Release staging repository by logging into Nexus Repository Manager and performing 'close' and then 'release' actions.

As an alternative to a CI release, you can perform a manual publish by following these steps:

  • Configure environment variables: nexusUsername, nexusPassword, signingKey, signingPassword;
  • Run gradle publish;
  • Login to Nexus Repository Manager and perform 'close' and then 'release' actions on a staged repository OR run gradle closeAndReleaseRepository.

Contributions

Contributions to this library are more than welcome. The easiest way to contribute is through GitHub issues and pull requests.

Free advertising for integrated apps

Once your app has a working Unstoppable Domains integration, register it here. Registered apps appear on the Unstoppable Domains homepage and Applications page — putting your app in front of tens of thousands of potential customers per day.

Also, every week we select a newly-integrated app to feature in the Unstoppable Update newsletter. This newsletter is delivered to straight into the inbox of ~100,000 crypto fanatics — all of whom could be new customers to grow your business.

Get help

Join our discord community and ask questions.

com.unstoppabledomains.resolution

Unstoppable Domains

Versions

Version
2.0.0u
1.0.0u
1.0.0