npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

arnacon-service

v1.0.17

Published

A simple npm module for registering subdomains on the Arnacon ENS system

Readme

ArnaconService

A simple npm module for registering subdomains on the Arnacon ENS system.

Installation

From GitHub (Recommended for development)

# Clone the repository
git clone https://github.com/YOUR_USERNAME/ArnaconService.git
cd ArnaconService

# Install dependencies
npm install

# Copy environment example and configure
cp .env.example .env
# Edit .env with your private key

As an npm dependency

npm install git+https://github.com/matan-fridman/ArnaconService.git

Quick Start

  1. Setup Environment Variables

    cp .env.example .env

    Edit .env and add your private key:

    PRIVATE_KEY=your_private_key_here_without_0x_prefix
  2. Run the Example

    npm run example
  3. Use in Your Project

    const ArnaconService = require('arnacon-service');
       
    async function main() {
        const service = new ArnaconService();
        const walletAddress = await service.init(process.env.PRIVATE_KEY);
           
        // Register a subdomain
        const result = await service.registerSubdomain(
            "myapp",          // label
            "example",        // parent domain
            walletAddress,    // owner address
            30               // duration in days
        );
           
        console.log("Registration successful:", result);
    }
       
    main().catch(console.error);

Usage

const ArnaconService = require('arnacon-service');

async function main() {
    const service = new ArnaconService();
    
    // Initialize with private key
    const privateKey = process.env.PRIVATE_KEY;
    const rpcUrl = "https://rpc-amoy.polygon.technology/"; // Optional, defaults to Polygon Amoy
    
    const walletAddress = await service.init(privateKey, rpcUrl);
    
    // Get owned names
    const names = await service.getOwnedNames();
    console.log("Owned names:", names);
    
    // Register a subdomain
    try {
        const result = await service.registerSubdomain(
            "test",           // label (subdomain)
            "example",        // parent domain name  
            walletAddress,    // owner address (optional, defaults to your wallet)
            10                // duration in days (optional, defaults to 10)
        );
        
        console.log("Registration successful:", result);
        // Output: test.example.global registered successfully
        
    } catch (error) {
        console.error("Registration failed:", error.message);
    }
}

main();

API Reference

new ArnaconService()

Creates a new instance of the ArnaconService.

init(privateKey, rpcUrl?, contractAddresses?)

Initializes the ArnaconService with a private key and network configuration.

Parameters:

  • privateKey (string): Private key for the wallet that will sign transactions
  • rpcUrl (string, optional): RPC URL for the blockchain network. Defaults to Polygon Amoy testnet
  • contractAddresses (object, optional): Object containing contract addresses. If not provided, will try to load from amoy-addresses.json

Returns: Promise resolving to the wallet address

registerSubdomain(label, name, ownerAddress?, durationInDays?)

Registers a new subdomain.

Parameters:

  • label (string): The subdomain label (e.g., "test" for test.example.global)
  • name (string): The parent domain name (e.g., "example" for test.example.global)
  • ownerAddress (string, optional): Address that will own the subdomain. Defaults to the signer's address
  • durationInDays (number, optional): Duration in days for the registration. Defaults to 10 days

Returns: Promise resolving to registration result object:

{
    success: true,
    subdomain: "test.example.global",
    owner: "0x123...",
    expiry: Date,
    transactionHash: "0xabc...",
    blockNumber: 12345
}

setContractAddresses(addresses)

Manually set contract addresses.

Parameters:

  • addresses (object): Object containing contract addresses

getWalletAddress()

Get the current wallet address.

Returns: String wallet address or null if not initialized

Contract Addresses

The module requires the following contract addresses to be available:

  • GlobalRegistrarController: Address of the global registrar controller contract

You can provide these addresses either:

  1. As a parameter to the init() function
  2. By calling setContractAddresses() after initialization
  3. By having them in an amoy-addresses.json file in the current directory

Example Contract Addresses Object

const contractAddresses = {
    "GlobalRegistrarController": "0x1234567890123456789012345678901234567890"
};

Error Handling

The module throws descriptive errors for common issues:

  • ArnaconService not initialized
  • Missing required parameters
  • Contract not found
  • Transaction failures

Always wrap calls in try-catch blocks for proper error handling.

License

MIT