Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Registration

Write methods require a connected viem WalletClient passed as the last argument.

register

Registers a name via the commit-reveal flow. The SDK handles the full sequence automatically:

  1. Generates a random secret
  2. Calls commit(makeCommitment(req))
  3. Waits MIN_COMMITMENT_AGE (60 seconds + 5s buffer)
  4. Collects payment and calls register(req, paymentToken)

Pay with ETH (default)

import { createWalletClient, custom } from "viem";
import { baseSepolia } from "viem/chains";
 
const walletClient = createWalletClient({
  chain: baseSepolia,
  transport: custom(window.ethereum),
});
 
const hash = await oniym.register(
  {
    name: "alice",
    tld: "web3",
    duration: 30 * 24 * 60 * 60,  // 30 days ($3); use 365 * 24 * 60 * 60 for 1 year ($15)
    owner: "0x...",               // defaults to walletClient.account.address
    reverseRecord: true,
    addresses: {
      eth: "0x11702b8eF5F882191Af862a7e27096C44A5e2B37",
    },
    texts: {
      twitter: "@alice",
    },
    onCommit: (hash) => console.log("Committed:", hash),
    onWaiting: (ms) => console.log(`Waiting ${ms / 1000}s...`),
  },
  walletClient,
);

Pay with USDC

Pass paymentToken: "usdc" to pay the exact USD amount with no ETH price exposure. The SDK automatically:

  1. Calls PriceOracle.priceUsdc() to get the exact USDC amount (e.g. 3_000000 for 30 days)
  2. Calls USDC.approve(controller, amount) — one extra transaction
  3. Calls register(req, usdcAddress) — no msg.value needed
const hash = await oniym.register(
  {
    name: "alice",
    tld: "web3",
    duration: 365 * 24 * 60 * 60,  // 1 year = exactly $15.00 USDC
    paymentToken: "usdc",
    reverseRecord: true,
  },
  walletClient,
);

RegisterOptions

interface RegisterOptions {
  name: string;                    // label only, e.g. "alice"
  tld: string;                     // TLD label, e.g. "web3"
  duration?: number;               // seconds — 30 days ($3/month), 365 days ($15/year)
  owner?: Address;                 // default: walletClient.account.address
  resolver?: Address;              // default: PublicResolver
  reverseRecord?: boolean;         // default: false
  paymentToken?: "eth" | "usdc";   // default: "eth"
  addresses?: Partial<Record<SupportedChain, string>>;
  texts?: Record<string, string>;
  onCommit?: (hash: Hash) => void;
  onWaiting?: (remainingMs: number) => void;
}

Returns: Hash — transaction hash of the register() call

renew

Renews an existing registration. No commit-reveal required.

Pay with ETH

const hash = await oniym.renew(
  {
    name: "alice",
    tld: "web3",
    duration: 365 * 24 * 60 * 60,  // 1 year
  },
  walletClient,
);

Pay with USDC

const hash = await oniym.renew(
  {
    name: "alice",
    tld: "web3",
    duration: 365 * 24 * 60 * 60,
    paymentToken: "usdc",
  },
  walletClient,
);

RenewOptions

interface RenewOptions {
  name: string;                    // label only, e.g. "alice"
  tld: string;                     // TLD label, e.g. "web3"
  duration?: number;               // seconds — default: 365 days
  paymentToken?: "eth" | "usdc";   // default: "eth"
}

Returns: Hash — transaction hash of the renew() call

setAddress

Set a chain address on an existing name.

const hash = await oniym.setAddress("kyy.web3", "sol", "solanaAddress...", walletClient);

Supported chains: "btc" | "eth" | "sol" | "sui" | "bnb"

setText

Set a text record on an existing name.

const hash = await oniym.setText("kyy.web3", "twitter", "@kyy", walletClient);

Common text record keys: twitter, github, url, email, avatar, description

setResolver

Set the resolver contract for a name. Requires owning the name.

const hash = await oniym.setResolver(
  "kyy.web3",
  "0xcdE3eD98423FbE098E24Bba9B634dFC3b449AC1C",
  walletClient,
);