Skip to content

https-asana-com/resolution-go

 
 

Repository files navigation

Test Lint Go Report Card GoDoc Unstoppable Domains Documentation Get help on Discord

resolution-go

resolution-go is a library for interacting with blockchain domain names. It can be used to retrieve payment addresses, IPFS hashes for decentralized websites, DNS records and other records types

resolution-go is primarily built and maintained by Unstoppable Domains.

resolution-go decentralized domains across two zones:

  • Crypto Name Service (CNS)
    • .crypto
  • Zilliqa Name Service (ZNS)
    • .zil

Usage

package main

import (
  "fmt"
  "github.com/Zilliqa/gozilliqa-sdk/provider"
  "github.com/ethereum/go-ethereum/ethclient"
  "github.com/unstoppabledomains/resolution-go"
  "github.com/unstoppabledomains/resolution-go/namingservice"
)

func main() {
  // Resolve .crypto
  cns, _ := resolution.NewCnsBuilder().Build()
  ethAddress, _ := cns.Addr("brad.crypto", "ETH")
  fmt.Println("ETH address for brad.crypto is", ethAddress)

  // Resolve .zil
  zns, _ := resolution.NewZnsBuilder().Build()
  btcAddress, _ := zns.Addr("brad.zil", "BTC")
  fmt.Println("BTC address for brad.zil is", btcAddress)

  // Detect domain naming service
  namingServices := map[string]resolution.NamingService{namingservice.CNS: cns, namingservice.ZNS: zns}
  domainToDetect := "ryan.crypto"
  namingServiceName, _ := resolution.DetectNamingService(domainToDetect)
  if namingServices[namingServiceName] != nil {
    resolvedAddress, _ := namingServices[namingServiceName].Addr(domainToDetect, "ETH")
    fmt.Println("ETH address for", domainToDetect, "is", resolvedAddress)
  }

  // Set custom Ethereum endpoint for CNS service
  ethContractBackend, _ := ethclient.Dial("https://mainnet.infura.io/v3/c5da69dfac9c4d9d96dd232580d4124e")
  cnsWithCustomBackend, _ := resolution.NewCnsBuilder().SetContractBackend(ethContractBackend).Build()
  allCnsRecords, _ := cnsWithCustomBackend.AllRecords("beresnev.crypto")
  fmt.Println("Records for beresnev.crypto", allCnsRecords)

  // Set custom Zilliqa endpoint for ZNS service
  zilliqaProvider := provider.NewProvider("https://api.zilliqa.com")
  znsWithCustomProvider, _ := resolution.NewZnsBuilder().SetProvider(zilliqaProvider).Build()
  allZnsRecords, _ := znsWithCustomProvider.AllRecords("brad.zil")
  fmt.Println("Records for brad.zil", allZnsRecords)
}

Network support

Library supports Ethereum mainnet and Zilliqa mainnet only.

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.

About

Golang library for resolving unstoppable domains

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%