🥷
Namespace
  • [ Introduction ]
    • ENS
    • Namespace
  • Official Links
  • [ Dapps ]
    • Overview
    • Onchain Subs (App)
      • Search & Register
      • Wizard
        • Listing an ENS Name
        • Features List
      • ENS Widget
      • Farcaster Frames
        • Default Frame
        • Custom Frame
    • Offchain Subs (DevPortal)
      • Subname create/manage
      • Resolver set
      • API keys
  • How-to Guides and Demos
  • [ Dev Docs ]
    • SDK
      • Offchain Manager
        • Installation
        • Generate API key
        • Create or Update Subname
        • DeleteSubname
        • IsSubnameAvailable
        • GetFilteredSubnames
        • AddressRecords
          • ChainName
        • TextRecords
        • DataRecords
      • Indexer Manager
        • Installation
        • Methods
        • GetL2Subname
        • GetL2Subnames
      • Mint Manager
        • Installation
        • GetMintDetails
        • GetMintTransactionParameters
        • IsSubnameAvailable
        • How To Mint L1 & L2 subname via mint-manager
      • Namespace Client (deprecated)
        • Installation
        • GetListedName
        • GetMintDetails
        • GetMintTransactionParameters
        • IsSubnameAvailable
        • GenerateAuthToken
    • APIs
      • Offchain Manager
      • Mint Manager
    • Infrastructure
      • Namespace L2 Subnames
  • [ ecosystem ]
    • Use Cases
  • [ Jobs ]
    • 🧑‍💻 Full-Stack Dev
    • 🥷 Dev-Rel Lead
    • 💼 BD Lead
Powered by GitBook
On this page
  • Usage
  • Return Type
  1. [ Dev Docs ]
  2. SDK
  3. Namespace Client (deprecated)

GetMintTransactionParameters

GetMintTransactionParameters function

GetMintTransactionParameters is a function which generates all the required parameters needed to send a successfull transaction and mint a subname on a given chain

Usage

index.ts
const listedName = await NamespaceClient.getListedName("example.eth", sepolia.id);
const minterAddress = "0x3E1e131E7e613D260F809E6BBE6Cbf7765EDC77f";
const subnameLabel = "hello";

const transactionParameters = await NamespaceClient
        .getMintTransactionParameters(listedName, {
                minterAddress,
                subnameLabel,
                subnameOwner: minterAddress
        });

Optionally, we can also provide records object so that we can mint a subname and set records in the same transaction

index.ts
const listedName = await NamespaceClient.getListedName("example.eth", sepolia.id);
const minterAddress = "0x3E1e131E7e613D260F809E6BBE6Cbf7765EDC77f";
const subnameLabel = "hello";

const transactionParameters = await NamespaceClient
        .getMintTransactionParameters(listedName, {
                minterAddress,
                subnameLabel,
                subnameOwner: minterAddress,
                records: {
                    texts: [ { key: "name", value: "John" } ],
                    addresses: [ { coinType: 60, address: minterAddress } ],
                    contenthash: "0x0" 
                }
        });

Return Type

This function returns parameters which can be used to mint a subname on a given chain:

export interface MintTransactionParameters {
  abi: Abi,
  contractAddress: Address
  functionName: string
  args: any[]
  value: bigint
  chain: Chain
}

Assuming we use Viem as a client for performing blockchain operations, we can use MintParameters to send a mint transaction

index.ts
import { createWalletClient, http } from "viem";
import { base } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";

const listedName = await NamespaceClient.getListedName("example.eth", sepolia.id);
const minterAddress = "0x3E1e131E7e613D260F809E6BBE6Cbf7765EDC77f";
const subnameLabel = "hello";

const transactionParameters = await NamespaceClient
        .getMintTransactionParameters(listedName, {
           minterAddress,
           subnameLabel,
           subnameOwner: minterAddress
        });
        
const wallet = privateKeyToAccount("0x0my-priv-key")
const walletClient = createWalletClient({
  transport: http(),
  chain: base,
  account: wallet
})

const transactionHash = await walletClient.writeContract({
  abi: transactionParameters.abi,
  args: transactionParameters.args,
  address: transactionParameters.contractAddress,
  functionName: transactionParameters.functionName,
  value: transactionParameters.value;
});
PreviousGetMintDetailsNextIsSubnameAvailable

Last updated 9 months ago