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

# Activate Identity SBT

> Activate a minted identity to enable full functionality

## Overview

After minting an Identity SBT, you must activate it to enable full functionality including score calculation and achievement claiming.

## Prerequisites

* **Minted Identity**: Must have successfully minted an Identity SBT
* **Wallet Connection**: Same wallet used for minting
* **Gas Fees**: Sufficient ETH for activation transaction
* **Not Already Activated**: Identity must be in minted state

## Activation Process

### 1. Check Identity Status

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Check if identity is activated
  const identity = await identityContract.getIdentity(userAddress);
  console.log('Identity status:', identity.status); // 'minted' or 'activated'

  // Check activation status
  const isActivated = await identityContract.isActivated(userAddress);
  console.log('Is activated:', isActivated);
  ```

  ```solidity Solidity theme={null}
  // Check status in contract
  (bool activated, uint256 tokenId) = identityContract.getActivationStatus(userAddress);
  ```
</CodeGroup>

### 2. Activate Identity

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Activate identity
  const tx = await identityContract.activateIdentity();
  await tx.wait();
  console.log('Identity activated!', tx.hash);
  ```

  ```solidity Solidity theme={null}
  // Activate in contract
  identityContract.activateIdentity();
  ```
</CodeGroup>

### 3. Verify Activation

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Verify activation
  const isActivated = await identityContract.isActivated(userAddress);
  console.log('Activation successful:', isActivated);

  // Check identity details
  const identity = await identityContract.getIdentity(userAddress);
  console.log('Identity:', identity);
  ```
</CodeGroup>

## Activation Requirements

### Prerequisites

* **Minted Identity**: Identity SBT must be minted
* **Valid Wallet**: Must be the identity owner
* **Sufficient Gas**: ETH for transaction fees
* **Not Activated**: Identity must be in minted state

### What Happens During Activation

1. **Status Update**: Identity status changes from `minted` to `activated`
2. **Score Calculation**: Triggers initial score calculation
3. **Event Emission**: `IdentityActivated` event is emitted
4. **Metadata Update**: Identity metadata is finalized

## Activation Events

### IdentityActivated Event

```solidity theme={null}
event IdentityActivated(
    address indexed user,
    uint256 indexed tokenId,
    string zksId,
    uint256 timestamp
);
```

### Event Handling

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Listen for activation events
  identityContract.on('IdentityActivated', (user, tokenId, zksId, timestamp) => {
    console.log(`Identity activated: ${zksId} (${user})`);
    console.log('Token ID:', tokenId.toString());
    console.log('Timestamp:', new Date(timestamp * 1000));
  });
  ```
</CodeGroup>

## Error Handling

### Common Errors

| Error                | Description                | Solution             |
| -------------------- | -------------------------- | -------------------- |
| `IDENTITY_NOT_FOUND` | No identity found          | Mint identity first  |
| `ALREADY_ACTIVATED`  | Identity already activated | Check current status |
| `NOT_IDENTITY_OWNER` | Not the identity owner     | Use correct wallet   |
| `ACTIVATION_FAILED`  | Activation process failed  | Retry transaction    |

### Error Handling Example

<CodeGroup>
  ```javascript JavaScript theme={null}
  try {
    const tx = await identityContract.activateIdentity();
    await tx.wait();
    console.log('Identity activated successfully!');
  } catch (error) {
    if (error.code === 'IDENTITY_NOT_FOUND') {
      console.error('No identity found. Mint an identity first.');
    } else if (error.code === 'ALREADY_ACTIVATED') {
      console.error('Identity is already activated.');
    } else {
      console.error('Activation failed:', error.message);
    }
  }
  ```
</CodeGroup>

## Post-Activation

### What You Can Do After Activation

1. **Score Calculation**: Scores will be calculated automatically
2. **Achievement Claiming**: Can claim achievements
3. **Attestation Creation**: Can create and receive attestations
4. **Identity Updates**: Can update profile information
5. **Cross-chain Usage**: Identity works across all supported networks

### Score Calculation Trigger

<CodeGroup>
  ```javascript JavaScript theme={null}
  // After activation, scores are calculated automatically
  // You can check score status
  const scoreStatus = await scoreCalculator.getScoreStatus(userAddress);
  console.log('Score calculation status:', scoreStatus);

  // Wait for score calculation to complete
  const score = await scoreCalculator.getScore(userAddress);
  console.log('User score:', score);
  ```
</CodeGroup>

## Best Practices

1. **Activate Immediately**: Activate after minting for best experience
2. **Monitor Events**: Listen for activation confirmation
3. **Handle Errors**: Implement proper error handling
4. **Verify Success**: Always verify activation completed
5. **Update UI**: Update user interface after activation

## Related Documentation

* [Mint Identity](/contracts/identity-sbt/mint)
* [Identity SBT Overview](/contracts/identity-sbt/overview)
* [Score Calculator](/contracts/score-calculator/overview)
