> ## Documentation Index
> Fetch the complete documentation index at: https://core.anylayer.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Mint Identity SBT

> Mint a new soulbound identity token with ZKS ID

## 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

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Check if ZKS ID is available
  const isAvailable = await identityContract.isZKSIdAvailable('alice.zks');
  console.log('ZKS ID available:', isAvailable);
  ```

  ```solidity Solidity theme={null}
  // Check availability in contract
  bool available = identityContract.isZKSIdAvailable('alice.zks');
  ```
</CodeGroup>

### 2. Mint Identity

<CodeGroup>
  ```javascript JavaScript theme={null}
  // 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);
  ```

  ```solidity Solidity theme={null}
  // Mint identity in contract
  identityContract.mintIdentity{value: mintingFee}(
    'alice.zks',
    'Alice Smith',
    'https://alice.example.com/avatar.jpg'
  );
  ```
</CodeGroup>

### 3. Verify Minting

<CodeGroup>
  ```javascript JavaScript theme={null}
  // 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);
  ```
</CodeGroup>

## 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

| Network  | Fee (ETH) | Fee (USD) |
| -------- | --------- | --------- |
| Ethereum | 0.01 ETH  | \~\$20    |
| Polygon  | 0.001 ETH | \~\$2     |
| Arbitrum | 0.001 ETH | \~\$2     |
| Base     | 0.001 ETH | \~\$2     |

### Fee Calculation

<CodeGroup>
  ```javascript JavaScript theme={null}
  // 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');
  ```
</CodeGroup>

## Error Handling

### Common Errors

| Error              | Description               | Solution                    |
| ------------------ | ------------------------- | --------------------------- |
| `ZKS_ID_TAKEN`     | ZKS ID already exists     | Choose different ZKS ID     |
| `IDENTITY_EXISTS`  | User already has identity | Cannot mint second identity |
| `INSUFFICIENT_FEE` | Not enough ETH for fee    | Add more ETH to wallet      |
| `INVALID_ZKS_ID`   | ZKS ID format invalid     | Use valid format (name.zks) |

### Error Handling Example

<CodeGroup>
  ```javascript JavaScript theme={null}
  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);
    }
  }
  ```
</CodeGroup>

## 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

## Related Documentation

* [Identity SBT Overview](/contracts/identity-sbt/overview)
* [Activate Identity](/contracts/identity-sbt/activate)
* [Contract Addresses](/contracts/addresses)
