nns

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 2

README

NNS

NNS - Neo Name Service is a service that allows manage a domain name as a digital asset (NFT). It has an interface similar to DNS but has significant differences in its internal structure.

Entities:

  • Domain
  • Record
  • Owner
  • Committee
Domain

Domain is string that satisfies the following requirements:

  • Length from 2 to 255 characters.
  • Root domain must start with a letter.
  • All other fragments must start and end with a letter or digit.

Domain has owner, a registration period, and may optionally have records.

A fee established by the committee is charged upon domain registration. After registration, the owner can manage this asset (add/delete records, transfer ownership to another owner) until the end of the domain registration period.

Record

A record is a pair of values <type, string>.

Supported record types:

Type Description
A Represents address record type
AAA Represents IPv6 address record type
TXT Represents text record type
CNAME Represents canonical name record type
SOA Represents start of authority record type
Owner

An owner is a wallet that has the right to manage this NFT (domain).

Committee

The committee makes new tokens (domains), sets, and charges a fee for issuance.

Globally Unique Domain Zone

For more information, see here.

NNS and Frostfsid

You can register a TLD domain without a committee signature using Frostfsid. To do this, create a new wallet

neo-go wallet init -w newwallet/wallet.json

Get wallet address:

neo-go wallet dump-keys -w newwallet/wallet.json
[subject-address]
[subject-key]

Create a subject in FrostfsID:

frostfs-adm morph frostfsid create-subject --subject-key="[subject-key]"

Grant permissions to the wallet:

frostfs-adm morph nns give-privilege --subject-address="[subject-address]"

Register domain:

neo-go contract invokefunction [NNS-hash] register   "subdomain.domain"  hash160:[subject-address]   "email@frostfs.info"   10000   1000   1000   1000 -- [subject-address]:Global

Documentation

Overview

Package nns contains non-divisible non-fungible NEP11-compatible token implementation. This token is a compatible analogue of C# Neo Name Service token and is aimed to serve as a domain name service for Neo smart-contracts, thus it's NeoNameService. This token can be minted with new domain name registration, the domain name itself is your NFT. Corresponding domain root must be added by committee before a new domain name can be registered.

Index

Constants

View Source
const (
	FrostfsIDNNSTLDPermissionKey    = "nns-allow-register-tld"
	FrostfsIDTLDRegistrationAllowed = "allow"
)
View Source
const (
	// Cnametgt is a special TXT record ensuring all created subdomains point to the global domain - the value of this variable.
	// It is guaranteed that two domains cannot point to the same global domain.
	Cnametgt = "cnametgt"
)
View Source
const FrostfsIDNNSName = "frostfsid.frostfs"

Variables

This section is empty.

Functions

func AddRecord

func AddRecord(name string, typ RecordType, data string)

AddRecord adds a new record of the specified type to the provided domain.

func BalanceOf

func BalanceOf(owner interop.Hash160) int

BalanceOf returns the overall number of domains owned by the specified owner.

func Decimals

func Decimals() int

Decimals returns NeoNameService decimals.

func DeleteDomain added in v0.20.0

func DeleteDomain(name string)

DeleteDomain deletes the domain with the given name.

func DeleteRecord added in v0.20.0

func DeleteRecord(name string, typ RecordType, data string) bool

DeleteRecord delete a record of the specified type by data in the provided domain. Returns false if the record was not found.

func DeleteRecords

func DeleteRecords(name string, typ RecordType)

DeleteRecords removes domain records with the specified type.

func GetAllRecords

func GetAllRecords(name string) iterator.Iterator

GetAllRecords returns an Iterator with RecordState items for the given name.

func GetPrice

func GetPrice() int

GetPrice returns the domain registration price.

func GetRecords

func GetRecords(name string, typ RecordType) []string

GetRecords returns domain record of the specified type if it exists or an empty string if not.

func IsAvailable

func IsAvailable(name string) bool

IsAvailable checks whether the provided domain name is available.

func OwnerOf

func OwnerOf(tokenID []byte) interop.Hash160

OwnerOf returns the owner of the specified domain.

func Properties

func Properties(tokenID []byte) map[string]any

Properties returns a domain name and an expiration date of the specified domain.

func Register

func Register(name string, owner interop.Hash160, email string, refresh, retry, expire, ttl int) bool

Register registers a new domain with the specified owner and name if it's available.

func Renew

func Renew(name string) int64

Renew increases domain expiration date.

func Resolve

func Resolve(name string, typ RecordType) []string

Resolve resolves given name (not more then three redirects are allowed).

func Roots

func Roots() iterator.Iterator

Roots returns iterator over a set of NameService roots.

func SetAdmin

func SetAdmin(name string, admin interop.Hash160)

SetAdmin updates domain admin.

func SetPrice

func SetPrice(price int64)

SetPrice sets the domain registration price.

func SetRecord

func SetRecord(name string, typ RecordType, id byte, data string)

SetRecord adds a new record of the specified type to the provided domain.

func Symbol

func Symbol() string

Symbol returns NeoNameService symbol.

func Tokens

func Tokens() iterator.Iterator

Tokens returns iterator over a set of all registered domain names.

func TokensOf

func TokensOf(owner interop.Hash160) iterator.Iterator

TokensOf returns iterator over minted domains owned by the specified owner.

func TotalSupply

func TotalSupply() int

TotalSupply returns the overall number of domains minted by NeoNameService contract.

func Transfer

func Transfer(to interop.Hash160, tokenID []byte, data any) bool

Transfer transfers the domain with the specified name to a new owner.

func Update

func Update(nef []byte, manifest string, data any)

Update updates NameService contract.

func UpdateSOA

func UpdateSOA(name, email string, refresh, retry, expire, ttl int)

UpdateSOA updates soa record.

func Version

func Version() int

Version returns the version of the contract.

Types

type NameState

type NameState struct {
	Owner      interop.Hash160
	Name       string
	Expiration int64
	Admin      interop.Hash160
}

NameState represents domain name state.

type RecordState

type RecordState struct {
	Name string
	Type RecordType
	Data string
	ID   byte
}

RecordState is a type that registered entities are saved to.

type RecordType

type RecordType byte

RecordType is domain name service record types.

const (
	// A represents address record type.
	A RecordType = 1
	// CNAME represents canonical name record type.
	CNAME RecordType = 5
	// SOA represents start of authority record type.
	SOA RecordType = 6
	// TXT represents text record type.
	TXT RecordType = 16
)

Record types are defined in [RFC 1035](https://tools.ietf.org/html/rfc1035)

const (
	// AAAA represents IPv6 address record type.
	AAAA RecordType = 28
)

Record types are defined in [RFC 3596](https://tools.ietf.org/html/rfc3596)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL