Prerequisites
- ENS Name Activation: Your ENS name must be activated on the Namespace platform
- Node.js: Version 16 or higher
- TypeScript: Basic understanding of TypeScript
- Web3 Knowledge: Familiarity with Ethereum and blockchain concepts
Getting Started
Activate Your ENS Name
Before you can mint subnames, your parent ENS name must be activated on the Namespace platform. This is a prerequisite for all subname minting operations.
How-to Activate ENS Name
See the step-by-step guide on how to activate an ENS Name.
Install Dependencies
Install the required packages in your TypeScript project. The SDK uses Viem under the hood for blockchain interactions.
Configure Mint Client
Create and configure an instance of the MintClient with your custom RPC URLs and mint source.Configuration Options:
mint-client.ts
customRpcUrls: Custom RPC endpoints for different networksmintSource: Identifier for your application (used for analytics)
Set Up Viem Clients
Create Viem public and wallet clients for blockchain interactions. These will handle reading blockchain state and sending transactions.Key Components:
web3-client.ts
publicClient: For reading blockchain state and simulating transactionswalletClient: For signing and sending transactionswallet: Your account instance for transaction signing
Check Subname Availability
Before minting, verify that your desired subname is available on the target network.
check-availability.ts
Get Mint Details and Pricing
Retrieve detailed information about the minting process, including costs and validation checks.What This Provides:
get-mint-details.ts
- Validation that the subname can be minted
- Estimated costs (base price + network fees)
- Any validation errors or restrictions
Generate Transaction Parameters
Create the transaction parameters needed to mint the subname, including any custom records you want to set.Available Record Types:
generate-transaction.ts
- Address Records: Set wallet addresses for different chains
- Text Records: Add custom metadata like descriptions, websites, social links
Simulate and Execute Transaction
Simulate the transaction first to ensure it will succeed, then execute it on the blockchain.Transaction Flow:
execute-mint.ts
- Simulation: Ensures the transaction will succeed before execution
- Execution: Sends the transaction to the blockchain
- Confirmation: Returns the transaction hash for tracking
Complete Example
Here’s a complete implementation that combines all the steps:complete-mint-example.ts
Environment Variables
Create a.env file with your configuration:
Error Handling
The SDK provides comprehensive error handling for common scenarios:- Subname already taken: Check availability before minting
- Insufficient funds: Ensure wallet has enough ETH for minting costs
- Invalid parameters: Validate input parameters before calling SDK methods
- Network issues: Handle RPC connection failures gracefully

