Smart Contracts
Contracts
HandshakeNft

HandshakeNft

Git Source (opens in a new tab)

Author: Sam Ward

Inherits: ERC721, Ownable

State Variables

TOKEN_URI_SELECTOR

bytes4 private constant TOKEN_URI_SELECTOR = bytes4(keccak256("tokenURI(bytes32)"));

tokenResolverMap

mapping(bytes32 => IResolver) public tokenResolverMap;

defaultResolver

IResolver defaultResolver;

metadata

IMetadataService public metadata;

Functions

constructor

constructor(string memory _symbol, string memory _name) ERC721(_symbol, _name);

tokenURI

function tokenURI(uint256 _id) public view override returns (string memory);

setMetadataContract

function setMetadataContract(IMetadataService _metadata) external onlyOwner;

setDefaultResolver

function setDefaultResolver(IResolver _resolver) external onlyOwner;

setResolver

function setResolver(bytes32 _namehash, IResolver _resolver) public virtual onlyApprovedOrOwner(uint256(_namehash));

supportsInterface

function supportsInterface(bytes4 interfaceId) public view override returns (bool);

ownerOf

Gets the owner of the specified token ID. Names become unowned when their registration expires.

function ownerOf(uint256 tokenId) public view virtual override(ERC721) returns (address);

Parameters

NameTypeDescription
tokenIduint256uint256 ID of the token to query the owner of

Returns

NameTypeDescription
<none>addressaddress currently marked as the owner of the given token ID

_isApprovedOrOwner

custom version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes expiration into consideration instead of ERC721.ownerOf(tokenId);

function _isApprovedOrOwner(address spender, uint256 tokenId) internal view override returns (bool);

Parameters

NameTypeDescription
spenderaddressaddress of the spender to query
tokenIduint256uint256 ID of the token to be transferred

Returns

NameTypeDescription
<none>boolbool whether spender is approved for the given token ID, is an operator of the owner, or is the owner of the token

isApprovedOrOwner

public version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes expiration into consideration instead of ERC721.ownerOf(tokenId);

function isApprovedOrOwner(address spender, uint256 tokenId) public view virtual returns (bool);

Parameters

NameTypeDescription
spenderaddressaddress of the spender to query
tokenIduint256uint256 ID of the token to be transferred

Returns

NameTypeDescription
<none>boolbool whether the spender is approved for the given token ID, is an operator of the owner, or is the owner of the token

name

returns back the string representation of the name. It makes more sense to have it here than on the resolver as the resolver can be updated and we will likely use the name string in the metadata class

should override this function in the inherited class

function name(bytes32 _namehash) external view virtual returns (string memory _name);

Parameters

NameTypeDescription
_namehashbytes32bytes32 representaion of the domain

Returns

NameTypeDescription
_namestringfully qualified name of the domain / NFT

parent

function parent(bytes32 _namehash) external view virtual returns (string memory _parentName);

expiry

function expiry(bytes32 _namehash) external view virtual returns (uint256 _expiry);

onlyApprovedOrOwner

modifier version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes expiration into consideration instead of ERC721.ownerOf(tokenId);

modifier onlyApprovedOrOwner(uint256 tokenId);

Parameters

NameTypeDescription
tokenIduint256uint256 ID of the token to be transferred

exists

Returns whether tokenId exists. Tokens can be managed by their owner or approved accounts via approve or setApprovalForAll. Tokens start existing when they are minted (_mint), and stop existing when they are burned (_burn).

function exists(uint256 tokenId) public view virtual returns (bool);