Mint L1 or L2 subnames using SDK
This guide will show you how to implement a subname minting functionality using Namespace-SDK
Namespace SDK is a typescript library, which can be used to interact with Namespace API and smart contracts. It currently allows devs to mint subnames under listed ENS names and abstracts the different chain logic.
1. Listing an ENS name
The prerequisite for minting is for the parent ENS name to be listed on the Namespace platform. This can be done using the Manager on our platform.
Listing ENS NameFor testing purposes, we can use an already listed name "mint-on-namespace.eth". This name is listed on the Sepolia testnet and the subnames will be minted on the BaseSepolia testnet.
Get in touch with us on our Discord channel or Namespace Devs Telegram group if you need some testnet ETH.
2. Installing namespace-sdk library
The second step would be to include namespace-SDK dependency in our typescript project. Since the SDK uses viem under the hood, we would also need to include it as a dependency.
yarn add namespace-sdk viem
3. Create a NamespaceClient instance
We will use createNamespaceClient
function to set up a Namespace Client with a given ChainId.
The ChainId specifies an id of a blockchain where the subnames are being minted from (In our case, since we will be using "mint-on-namespace.eth", we will specify baseSepolia.id (84532), this is so that viem knows which chain to look at when it simulates the mint transaction or when it checks for subname availability.
Parameters
Parameter | Required | Description |
---|---|---|
chainId | true | Specifies chain id where subnames are minted from, supported chains include |
mintSource | false | Used to track the source of minted subnames on a blockchain, defaults to "namespace-sdk". |
rpcUrl | false | Http RPC URL which will be used by SDK when it performs blockchain operations, defaults to a public RPC for a given chain |
4. Getting a listed name and checking for subname availability
Now that we have our NamespaceClient, we can use it to fetch the listed name and check for subname availability.
5. Getting mint transaction parameters
Mint transaction parameters return all the needed values for executing a mint transaction
6. Execute mint transaction
Now that we have all the required parameters, we can use all this to execute a mint transaction and mint a subname, using our preferred client library.
We have now minted a subname on the BaseSepolia chain! We can now verify that it gets resolved on the ENS app using the URL: https://app.ens.domains/your-full-name.eth ( remember to switch to the Sepolia network if you've been using mint-on-namespace.eth )
Last updated