Join the Rootstock Open Slack Community to get the latest updates from the Rootstock Ecosystem!

Rootstock (RSK) Owner

Owner of rsk top level domain. It can setSubdomainOwner in RNS.

  • It represents domain ownership implementing ERC-7211 non-fungible token standard. This standard provides basic functionality to track and transfer NFTs2.
  • Stores domains' expiration time. The expiration time determines whether a domain is owned or not.
  • Determines if a domain is available to be purchased.
  • Accepts domain ownership clamming from previous rsk registrar.
  • Grants access to other contracts for registering new domains (registrar role)2.
  • Grants access to other contracts for renewing domains (renewer role)2.
  • Allows to reclaim ownership in RNS of owned domains.
  • It has an owner that can2
    • Change rsk tld resolver and ttl.
    • Add/remove registrar contracts.
    • Add/remove renewer contracts.

Implementation

Rootstock (RSK) Owner is an Ownable contract and represents domain labels ownership fully compatible with ERC-721 interface using OpenZeppelin's implementation.

The implementation is divided into two main parts: The public methods exposed by Rootstock (RSK) Owner, and the restricted access methods to manage upgrades to the solution. The latter will not be described in this article.

Public methods

The term domain label refers to the name that is added behind .rsk. For example, to register 'domain.rsk' one should use keccak256('domain') for tokenId parameters.

available

function available(uint256 tokenId) public view returns(bool);

Gets the owner of the specified domain.

  • tokenId keccak256 of the domain label.

Returns domain owner.

balanceOf

function balanceOf(address owner) public view returns (uint256 balance);

Gets the amount of domains owned by the specified address.

  • owner address to query the balance of.

Returns the amount owned by the passed address.

ownerOf

function ownerOf(uint256 tokenId) public view returns (address owner);

Gets the owner of the specified domain.

  • tokenId keccak256 of the domain label to query the owner of.

Returns address currently marked as the owner of the given domain.

transferFrom

function transferFrom(address from, address to, uint256 tokenId) public;

Transfers the ownership of a given token ID to another address.

Usage of this method is discouraged, use safeTransferFrom whenever possible. Requires the msg.sender to be the owner, approved, or operator.

  • from current owner of the domain.
  • to address to receive the ownership of the given domain.
  • tokenId keccak256 of the domain label to be transferred.

approve

function approve(address to, uint256 tokenId) public;

Approves another address to transfer the given domain label.

The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.

  • to address to be approved for the given tokenId.
  • tokenId keccak256 of the domain label to be approved.

getApproved

function getApproved(uint256 tokenId) public view returns (address operator);

Gets the approved address for a domain, or zero if no address set.

  • tokenId keccak256 of the domain label to query the approval of.

Returns currently approved for the given domain.

setApprovalForAll

function setApprovalForAll(address operator, bool _approved) public;

Sets or unsets the approval of a given operator. An operator is allowed to transfer all tokens of the sender on their behalf.

  • to operator address to set the approval.
  • approved representing the status of the approval to be set.

isApprovedForAll

function isApprovedForAll(address owner, address operator) public view returns (bool);

Tells whether an operator is approved by a given owner.

  • owner owner address which you want to query the approval of.
  • operator operator address which you want to query the approval of

Returns whether the given operator is approved by the given owner.

safeTransferFrom

function safeTransferFrom(address from, address to, uint256 tokenId) public;

Safely transfers the ownership of a given domain to another address.

If the target address is a contract, it must implement onERC721Received, which is called upon a safe transfer, and return the magic value bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")); otherwise, the transfer is reverted.

Requires the msg.sender to be the owner, approved, or operator.

  • from current owner of the domain.
  • to address to receive the ownership of the given domain.
  • tokenId keccak256 of the domain label to be transferred.
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public;
  • _data bytes data to send along with a safe transfer check.

supportsInterface

function supportsInterface(bytes4 interfaceId) external view returns (bool);

Returns true if this contract implements the interface defined by interfaceId, based on ERC-165 standard for interface detection.

This function call costs less than 30 000 gas.


  1. Strongly based on https://github.com/ensdomains/ethregistrar.
  2. https://github.com/OpenZeppelin/openzeppelin-contracts implementation.

Receive updates

Get the latest updates from the Rootstock ecosystem

Loading...