Add your own Custom Resolver

We are committed to continuous improvement

You can implement your resolver service and add pass it to RedefinedResolver.

Step 1. Extend ResolverService class

Please see GitHub for sources here

export abstract class ResolverService {
    abstract vendor: ResolverVendor;
    abstract resolve(domain: string, options?: ResolverServiceOptions, networks?: string[]): Promise<Account[]>;
}

Example:

export class KeyValueResolverService extends ResolverService {

    vendor: ResolverVendor = "keyvalue"
    
    registry = {
        "ivan": "0x1",
        "stepan": "0x2",
        "andrey": "0x3",
    }

    async resolve(domain: string, { throwErrorOnInvalidDomain }: ResolverServiceOptions = defaultResolverServiceOptions): Promise<Account[]> {
        const address = registry[domain];
        return address ? [{ address, network: "evm", from: this.vendor }] : [];
    }
}

Step 2. Register your ResolverService in RedefinedResolver

Initialize RedefinedResolver with your ResolverService only:

Or combine it with existing built-in resolver services:

Step 3. Implement SupportReverse interface if your resolver is capable of domain lookup by address

Contribute!

Open a pull request with your new ResolverService in our GitHub and help the community!

Last updated