Custom Resolvers
Overview
Custom resolvers allow you to implement specialized resolution logic and store additional data for domains.
Implementation Example
// Custom resolver with social media handles
contract SocialMediaResolver {
    PNS pns;
    mapping(bytes32 => string) twitter;
    mapping(bytes32 => string) github;
    
    constructor(PNS _pns) {
        pns = _pns;
    }
    
    modifier onlyOwner(bytes32 node) {
        require(pns.owner(node) == msg.sender);
        _;
    }
    
    function setTwitter(bytes32 node, string calldata handle) 
        external 
        onlyOwner(node) 
    {
        twitter[node] = handle;
    }
    
    function setGithub(bytes32 node, string calldata profile)
        external
        onlyOwner(node)
    {
        github[node] = profile;
    }
}Deployment and Setup
- Deploy Custom Resolver 
const customResolver = await SocialMediaResolver.deploy(
    PNS_REGISTRY_ADDRESS
);- Set Resolver for Domain 
// Through PNS Registry
await pnsRegistry.setResolver(
    namehash("domain.dot"), 
    customResolver.address
);- Configure Records 
await customResolver.setTwitter(
    namehash("domain.dot"),
    "@handle"
);Last updated