Skip to main content

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

// 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);

2. Activate Identity

// Activate identity
const tx = await identityContract.activateIdentity();
await tx.wait();
console.log('Identity activated!', tx.hash);

3. Verify Activation

// 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);

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

event IdentityActivated(
    address indexed user,
    uint256 indexed tokenId,
    string zksId,
    uint256 timestamp
);

Event Handling

// 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));
});

Error Handling

Common Errors

ErrorDescriptionSolution
IDENTITY_NOT_FOUNDNo identity foundMint identity first
ALREADY_ACTIVATEDIdentity already activatedCheck current status
NOT_IDENTITY_OWNERNot the identity ownerUse correct wallet
ACTIVATION_FAILEDActivation process failedRetry transaction

Error Handling Example

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);
  }
}

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

// 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);

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