Registry Contract
Last updated
Last updated
The RegistryContract
is a wrapper for the native contract that encapsulates the necessary logic for interacting with it. It provides the following methods:
: Mints a new handle.
: Transfers ownership.
: Sets a new resolver address.
: Sets new metadata.
: Retrieves the metadata of a handle.
To create an instance, you need to import the module from @bako-id/sdk
and call the constructor method. This method accepts either a Provider
or an Account
:
This method encapsulates the logic for registering a new handle by validating whether the handle name follows a valid string pattern, adding the necessary funds for the transaction, ensuring that the resolver address is either an Address
or a Contract ID
, and executing the contract call.
The method receives an object of type RegisterPayload
with the following properties:
domain
string
The handle name. Valid characters: A-Z, a-z, 0-9 @_
period
number
The number of years for the handle.
resolver
string
The resolver address of the handle.
The method throw an error when:
The contract is not connected to an account:
throw new Error('Account is required to register a domain')
The name of handle have invalid chars:
throw new InvalidDomainError()
The account not have sufficient funds:
throw new NotFoundBalanceError()
This method encapsulates the logic for transferring the ownership of the name to another address.
domain
string
The handle name. Valid characters: A-Z, a-z, 0-9, @_
address
string
The address of the new owner of the handle.
The method throw an error when:
The contract is not connected to an account:
throw new Error('Account is required to register a domain')
The name of handle have invalid chars:
throw new InvalidDomainError()
This method encapsulates the logic for changing the resolver address of the handle.
domain
string
The handle name. Valid characters: A-Z, a-z, 0-9, @_
address
string
The address of the new resolver for the handle.
The method throw an error when:
The contract is not connected to an account:
throw new Error('Account is required to register a domain')
The name of handle have invalid chars:
throw new InvalidDomainError()
This method encapsulates the logic for adding metadata to the handle.
domain
string
The handle name. Valid characters: A-Z, a-z, 0-9, @_
metadata
Record<MetadataKeys, string>
The keys and values of the metadata to be included.
The method throw an error when:
The contract is not connected to an account:
throw new Error('Account is required to register a domain')
The name of handle have invalid chars:
throw new InvalidDomainError()
The handle is not registered
throw new Error('Domain not found')
This method retrieves all the metadata for a handle.
domain
string
The handle name. Valid characters: A-Z, a-z, 0-9, @_
The method throw an error when:
The name of handle have invalid chars:
throw new InvalidDomainError()
The handle is not registered
throw new Error('Domain not found')
The method receives an object of type with the following properties:
The method receives an object of type with the following properties: