Skip to main content

Overview

Mint a new Identity SBT (Soulbound Token) to create a decentralized identity with a human-readable ZKS ID.

Prerequisites

  • Wallet Connection: Connected Web3 wallet
  • ZKS ID Available: Desired ZKS ID must be available
  • Gas Fees: Sufficient ETH for transaction fees
  • No Existing Identity: User must not already have an identity

Minting Process

1. Check Availability

// Check if ZKS ID is available
const isAvailable = await identityContract.isZKSIdAvailable('alice.zks');
console.log('ZKS ID available:', isAvailable);

2. Mint Identity

// Mint new identity
const tx = await identityContract.mintIdentity(
  'alice.zks', // ZKS ID
  'Alice Smith', // display name
  'https://alice.example.com/avatar.jpg', // avatar URL
  { value: mintingFee } // minting fee in wei
);

await tx.wait();
console.log('Identity minted!', tx.hash);

3. Verify Minting

// Check if identity was minted
const identity = await identityContract.getIdentity(userAddress);
console.log('Identity:', identity);

// Check ZKS ID resolution
const resolvedAddress = await identityContract.resolveZKSId('alice.zks');
console.log('Resolved address:', resolvedAddress);

Minting Parameters

Required Parameters

  • zksId: Human-readable identifier (e.g., alice.zks)
  • displayName: User’s display name
  • avatarUrl: URL to user’s avatar image

Optional Parameters

  • bio: User biography/description
  • website: Personal website URL
  • socialLinks: Array of social media links

Minting Fees

Fee Structure

NetworkFee (ETH)Fee (USD)
Ethereum0.01 ETH~$20
Polygon0.001 ETH~$2
Arbitrum0.001 ETH~$2
Base0.001 ETH~$2

Fee Calculation

// Get current minting fee
const mintingFee = await identityContract.mintingFee();
console.log('Minting fee:', ethers.utils.formatEther(mintingFee), 'ETH');

// Calculate total cost including gas
const gasEstimate = await identityContract.estimateGas.mintIdentity(
  'alice.zks',
  'Alice Smith',
  'https://alice.example.com/avatar.jpg',
  { value: mintingFee }
);

const gasPrice = await provider.getGasPrice();
const totalCost = mintingFee.add(gasEstimate.mul(gasPrice));
console.log('Total cost:', ethers.utils.formatEther(totalCost), 'ETH');

Error Handling

Common Errors

ErrorDescriptionSolution
ZKS_ID_TAKENZKS ID already existsChoose different ZKS ID
IDENTITY_EXISTSUser already has identityCannot mint second identity
INSUFFICIENT_FEENot enough ETH for feeAdd more ETH to wallet
INVALID_ZKS_IDZKS ID format invalidUse valid format (name.zks)

Error Handling Example

try {
  const tx = await identityContract.mintIdentity(
    'alice.zks',
    'Alice Smith',
    'https://alice.example.com/avatar.jpg',
    { value: mintingFee }
  );
  
  await tx.wait();
  console.log('Identity minted successfully!');
} catch (error) {
  if (error.code === 'ZKS_ID_TAKEN') {
    console.error('ZKS ID is already taken');
  } else if (error.code === 'IDENTITY_EXISTS') {
    console.error('User already has an identity');
  } else {
    console.error('Minting failed:', error.message);
  }
}

Best Practices

  1. Check Availability First: Always verify ZKS ID is available
  2. Handle Errors Gracefully: Implement proper error handling
  3. Estimate Gas: Calculate total cost before minting
  4. Store Transaction Hash: Keep record of minting transaction
  5. Verify Success: Confirm identity was created successfully