Copy 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
});
Copy 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"
}
});
This function returns parameters which can be used to mint a subname on a given chain:
Copy 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
Copy 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;
});