PNS SDK
The PNS SDK documentation serves as a technical reference for developers to integrate polkadot domain name services into applications.
Links
Functions
namehash(name: string): string
namehash(name: string): string
Returns the EIP-137 namehash for the provided domain name.
setupNameRegistry(registryAddress: Address, controllerAddress: Address, provider: JsonRpcProvider): {resolver: Resolver, registry: Registry, controller: Controller}
setupNameRegistry(registryAddress: Address, controllerAddress: Address, provider: JsonRpcProvider): {resolver: Resolver, registry: Registry, controller: Controller}
Sets up the name registry contracts and returns Resolver
, Registry
and Controller
contract instances.
registryAddress
- The address of the name registry contractcontrollerAddress
- The address of the controller contractprovider
- The JSON RPC provider instance
Returns an object containing the resolver
, registry
and controller
contract instances.
getFee(controller: Controller, name: string, duration: number): Promise<BigNumber>
getFee(controller: Controller, name: string, duration: number): Promise<BigNumber>
Gets the registration fee for a domain name and duration.
controller
- The controller contract instancename
- The domain nameduration
- The duration in years
Returns a BigNumber
representing the registration fee.
nameRegister(controller: Controller, name: string, addr: Address, duration: number): Promise<TransactionResponse>
nameRegister(controller: Controller, name: string, addr: Address, duration: number): Promise<TransactionResponse>
Registers a domain name.
controller
- The controller contract instancename
- The domain nameaddr
- The address to register the domain toduration
- The registration duration in years
Returns a Promise
which resolves to the transaction response.
nameRegisterExtended(controller: Controller, name: string, addr: Address, duration: number, setReverse: boolean, keys: string[], values: string[]): Promise<TransactionResponse>
nameRegisterExtended(controller: Controller, name: string, addr: Address, duration: number, setReverse: boolean, keys: string[], values: string[]): Promise<TransactionResponse>
Registers a domain name and configures records.
controller
- The controller contract instancename
- The domain nameaddr
- The address to register the domain toduration
- The registration duration in yearssetReverse
- Whether to set a reverse recordkeys
- The record keysvalues
- The record values
Returns a Promise
which resolves to the transaction response.
nameRegisterByManager(controller: Controller, name: string, addr: Address, duration: number, setReverse: boolean, keys: string[], values: string[]): Promise<TransactionResponse>
nameRegisterByManager(controller: Controller, name: string, addr: Address, duration: number, setReverse: boolean, keys: string[], values: string[]): Promise<TransactionResponse>
Registers a domain name by the manager.
Same parameters as nameRegisterExtended
.
Returns a Promise
which resolves to the transaction response.
ownerOfId(registry: Registry, tokenId: string): Promise<Address>
ownerOfId(registry: Registry, tokenId: string): Promise<Address>
Gets the owner of a domain token ID.
registry
- The registry contract instancetokenId
- The domain token ID
Returns a Promise
resolving to the owner address.
ownerOfName(registry: Registry, name: string): Promise<Address>
ownerOfName(registry: Registry, name: string): Promise<Address>
Gets the owner of a domain name.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the owner address.
exists(registry: Registry, name: string): Promise<boolean>
exists(registry: Registry, name: string): Promise<boolean>
Checks if a domain name exists.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to a boolean indicating if the domain exists.
getOwner(registry: Registry, name: string): Promise<Address>
getOwner(registry: Registry, name: string): Promise<Address>
Gets the owner of a domain name if it exists.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the owner address or zero address if it does not exist.
registerPrice(controller: Controller, name: string, duration: number): Promise<BigNumber>
registerPrice(controller: Controller, name: string, duration: number): Promise<BigNumber>
Gets the registration price for a domain name.
controller
- The controller contract instancename
- The domain nameduration
- The registration duration in years
Returns a Promise
resolving to the registration price as a BigNumber
.
renewPrice(controller: Controller, name: string, duration: number): Promise<BigNumber>
renewPrice(controller: Controller, name: string, duration: number): Promise<BigNumber>
Gets the renewal price for a domain name.
controller
- The controller contract instancename
- The domain nameduration
- The renewal duration in years
Returns a Promise
resolving to the renewal price as a BigNumber
.
basePrice(controller: Controller, name: string): Promise<BigNumber>
basePrice(controller: Controller, name: string): Promise<BigNumber>
Gets the base price for a domain name.
controller
- The controller contract instancename
- The domain name
Returns a Promise
resolving to the base price as a BigNumber
.
rentPrice(controller: Controller, name: string, duration: number): Promise<BigNumber>
rentPrice(controller: Controller, name: string, duration: number): Promise<BigNumber>
Gets the rent price for a domain name and duration.
controller
- The controller contract instancename
- The domain nameduration
- The duration in years
Returns a Promise
resolving to the rent price as a BigNumber
.
getPrices(controller: Controller): Promise<{basePrice: BigNumber, rentPrice: BigNumber, premiums: number[]}>
getPrices(controller: Controller): Promise<{basePrice: BigNumber, rentPrice: BigNumber, premiums: number[]}>
Gets the price configuration.
controller
- The controller contract instance
Returns a Promise
resolving to an object containing the price configuration.
getTokenPrice(controller: Controller): Promise<BigNumber>
getTokenPrice(controller: Controller): Promise<BigNumber>
Gets the current token price.
controller
- The controller contract instance
Returns a Promise
resolving to the current token price as a BigNumber
.
expire(registry: Registry, name: string): Promise<BigNumber>
expire(registry: Registry, name: string): Promise<BigNumber>
Gets the expiration time of a domain name.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the expiration time as a BigNumber
timestamp.
available(registry: Registry, name: string): Promise<boolean>
available(registry: Registry, name: string): Promise<boolean>
Checks if a domain name is available.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to a boolean indicating if the name is available.
parent(registry: Registry, name: string): Promise<BigNumber>
parent(registry: Registry, name: string): Promise<BigNumber>
Gets the parent token ID of a domain name.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the parent token ID as a BigNumber
.
origin(registry: Registry, name: string): Promise<BigNumber>
origin(registry: Registry, name: string): Promise<BigNumber>
Gets the origin token ID of a domain name.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the origin token ID as a BigNumber
.
mintSubdomain(registry: Registry, owner: Address, name: string, label: string): Promise<TransactionResponse>
mintSubdomain(registry: Registry, owner: Address, name: string, label: string): Promise<TransactionResponse>
Mints a new subdomain.
registry
- The registry contract instanceowner
- The new owner addressname
- The parent domain namelabel
- The subdomain label
Returns a Promise
resolving to the transaction response.
approve(registry: Registry, name: string, operator: Address): Promise<TransactionResponse>
approve(registry: Registry, name: string, operator: Address): Promise<TransactionResponse>
Approves an operator for a domain.
registry
- The registry contract instancename
- The domain nameoperator
- The approved operator address
Returns a Promise
resolving to the transaction response.
getApproved(registry: Registry, name: string): Promise<Address>
getApproved(registry: Registry, name: string): Promise<Address>
Gets the approved operator for a domain.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the approved operator address.
setName(resolver: Resolver, address: Address, name: string): Promise<TransactionResponse>
setName(resolver: Resolver, address: Address, name: string): Promise<TransactionResponse>
Sets the reverse record name for an address.
resolver
- The resolver contract instanceaddress
- The addressname
- The reverse name
Returns a Promise
resolving to the transaction response.
getName(resolver: Resolver, address: Address): Promise<string>
getName(resolver: Resolver, address: Address): Promise<string>
Gets the reverse record name for an address.
resolver
- The resolver contract instanceaddress
- The address
Returns a Promise
resolving to the reverse name.
setNftName(resolver: Resolver, nftAddress: Address, tokenId: string, nameTokenId: BigNumber): Promise<TransactionResponse>
setNftName(resolver: Resolver, nftAddress: Address, tokenId: string, nameTokenId: BigNumber): Promise<TransactionResponse>
Sets the reverse record name for an NFT.
resolver
- The resolver contract instancenftAddress
- The NFT contract addresstokenId
- The NFT token IDnameTokenId
- The name token ID to set
Returns a Promise
resolving to the transaction response
Here is more of the suggested SDK documentation:
getNftName(resolver: Resolver, nftAddress: Address, tokenId: string): Promise<BigNumber>
getNftName(resolver: Resolver, nftAddress: Address, tokenId: string): Promise<BigNumber>
Gets the reverse record name for an NFT.
resolver
- The resolver contract instancenftAddress
- The NFT contract addresstokenId
- The NFT token ID
Returns a Promise
resolving to the name token ID.
getKey(resolver: Resolver, name: string, key: string): Promise<string>
getKey(resolver: Resolver, name: string, key: string): Promise<string>
Gets a specific text record for a domain.
resolver
- The resolver contract instancename
- The domain namekey
- The text record key
Returns a Promise
resolving to the text record value.
setKeysByHash(resolver: Resolver, name: string, keys: string[], values: string[]): Promise<TransactionResponse>
setKeysByHash(resolver: Resolver, name: string, keys: string[], values: string[]): Promise<TransactionResponse>
Sets multiple text records by hash for a domain.
resolver
- The resolver contract instancename
- The domain namekeys
- The text record key hashesvalues
- The text record values
Returns a Promise
resolving to the transaction response.
getKeys(resolver: Resolver, name: string, keys: string[]): Promise<string[]>
getKeys(resolver: Resolver, name: string, keys: string[]): Promise<string[]>
Gets multiple text records for a domain.
resolver
- The resolver contract instancename
- The domain namekeys
- The text record keys
Returns a Promise
resolving to an array of text record values.
getKeysByHash(resolver: Resolver, name: string, hashes: string[]): Promise<string[]>
getKeysByHash(resolver: Resolver, name: string, hashes: string[]): Promise<string[]>
Gets multiple text records by hash for a domain.
resolver
- The resolver contract instancename
- The domain namehashes
- The text record hashes
Returns a Promise
resolving to an array of text record values.
renew(controller: Controller, name: string, duration: number): Promise<TransactionResponse>
renew(controller: Controller, name: string, duration: number): Promise<TransactionResponse>
Renews a domain registration.
controller
- The controller contract instancename
- The domain nameduration
- The renewal duration in years
Returns a Promise
resolving to the transaction response.
renewByManager(controller: Controller, name: string, duration: number): Promise<TransactionResponse>
renewByManager(controller: Controller, name: string, duration: number): Promise<TransactionResponse>
Renews a domain registration via the manager.
controller
- The controller contract instancename
- The domain nameduration
- The renewal duration in years
Returns a Promise
resolving to the transaction response.
transferName(registry: Registry, name: string, owner: Address): Promise<TransactionResponse>
transferName(registry: Registry, name: string, owner: Address): Promise<TransactionResponse>
Transfers ownership of a domain to a new owner.
registry
- The registry contract instancename
- The domain nameowner
- The new owner address
Returns a Promise
resolving to the transaction response.
burn(registry: Registry, name: string): Promise<TransactionResponse>
burn(registry: Registry, name: string): Promise<TransactionResponse>
Burns a domain.
registry
- The registry contract instancename
- The domain name
Returns a Promise
resolving to the transaction response.
Last updated