Contracts
NNS smart contracts form the backbone of Nad Name Service, powering its functionality on the Monad blockchain. These contracts manage the registration, administration, and transfer of human-readable names, ensuring security and transparency without relying on centralized authorities.
Contract addressesContract ABINadNameService.sol
This is the core contract of Nad Name Service. It provides a standardized way to interact with the protocol, allowing developers to:
Resolve names to address
Obtain the primary name for an address
Manage and retrieve attributes associated with names
interface INadNameService {
struct Attribute {
string key;
string value;
}
struct ResolvedAddressItem {
bytes32 node;
address addr;
}
struct PrimaryNameItem {
address addr;
string primaryName;
}
struct Profile {
address addr;
string primaryName;
string avatar;
}
/**
* @notice Emitted when a name's attribute is set.
* @param node the hash of the name that attribute was set for
* @param key the key of the attribute that was set
* @param value the value of the attribute that was set
*/
event AttributeSet(bytes32 indexed node, string key, string value);
/**
* @notice Emitted when multiple attributes for a name are set.
* @param node the hash of the name that attributes were set for
* @param attributes an array of attributes with the keys and values
*/
event AttributesSet(bytes32 indexed node, Attribute[] attributes);
/**
* @notice Get the resolved address for a name.
* @param node the hash of the name to get the resolved address for
* @return the resolved address
*/
function getResolvedAddress(
bytes32 node
) external view returns (address);
/**
* @notice Get the resolved addresses for a list of names.
* @param nodes the hashes of the names to get the resolved addresses for
* @return an array of ResolvedAddressItem structs containing the node and address
*/
function getResolvedAddresses(
bytes32[] calldata nodes
) external view returns (ResolvedAddressItem[] memory);
/**
* @notice Get the primary name for a node.
* @param node The node address to get the primary name for
* @return The primary name for the address
*/
function getPrimaryNameForNode(
bytes32 node
) external view returns (string memory);
/**
* @notice Get the primary name for an address.
* @param addr The address to get the primary name for
* @return The primary name for the address
*/
function getPrimaryNameForAddress(
address addr
) external view returns (string memory);
/**
* @notice Get the primary names for a list of addresses.
* @param addr The addresses to get the primary names for
* @return An array of PrimaryNameItem structs containing the address and primary name
*/
function getPrimaryNameForAddresses(
address[] calldata addr
) external view returns (PrimaryNameItem[] memory);
/**
* @notice Set an attribute for a name.
* @param node the hash of the name to set the attribute for
* @param key the key of the attribute to set
* @param value the value of the attribute to set
*/
function setNameAttribute(
bytes32 node,
string calldata key,
string calldata value
) external;
/**
* @notice Set multiple attributes for a name.
* @param node the hash of the name to set the attributes for
* @param attributes an array of attributes with the keys and values
*/
function setNameAttributes(
bytes32 node,
Attribute[] calldata attributes
) external;
/**
* @notice Get an attribute for a name.
* @param node the hash of the name to get the attribute for
* @param key the key of the attribute to get
* @return result value of the attribute
*/
function getNameAttribute(
bytes32 node,
string calldata key
) external view returns (string memory);
/**
* @notice Get multiple attributes for a name
* @param node the hash of the name to get the attributes for
* @param keys the keys of the attributes to get
* @return result an array of attributes with the keys and values
*/
function getNameAttributes(
bytes32 node,
string[] calldata keys
) external view returns (Attribute[] memory);
/**
* @notice Get a profile for an address, containing primary name and avatar
* @param addr the address to get the profile
* @return profile the profile of the address, including primary name and avatar
*/
function getProfileForAddress(
address addr
) external view returns (Profile memory);
/**
* @notice Get a list of profiles for a list of addresses
* @param addrs the addresses to get the profiles for
* @return profiles the profiles of the addresses, including primary name and avatar
*/
function getProfilesForAddresses(
address[] calldata addrs
) external view returns (Profile[] memory);
}
Last updated