Overview
The ZKScore Identity SBT (Soulbound Token) is the core smart contract that manages ZKS identities on the blockchain. It implements the ERC-721 standard with soulbound token mechanics, ensuring that identities cannot be transferred once activated, making them truly soulbound to their owners.Contract Architecture
Core Components
The Identity SBT contract consists of several key components:- ERC-721 Base: Standard NFT functionality for metadata and ownership
- Soulbound Mechanics: Prevents transfer after activation
- Access Control: Role-based permissions for minting and management
- Metadata Management: On-chain and off-chain metadata storage
- Event System: Comprehensive event logging for indexing
Key Features
- Soulbound Tokens: Once activated, tokens cannot be transferred
- Metadata Flexibility: Support for both on-chain and off-chain metadata
- Role-Based Access: Granular permissions for different operations
- Gas Optimization: Efficient storage and operation patterns
- Upgrade Safety: Immutable core logic with configurable parameters
Contract Addresses
Mainnet Deployments
Testnet Deployments
Contract Interface
Core Functions
Events
Soulbound Token Mechanics
What Makes It Soulbound
The Identity SBT implements soulbound token mechanics through several mechanisms:- Transfer Prevention: Once activated, the
transferFromandsafeTransferFromfunctions revert - Approval Blocking: Approval functions are disabled for activated tokens
- Immutable Ownership: Token ownership cannot be changed after activation
- Metadata Locking: Metadata becomes immutable after activation
Activation Process
Metadata Structure
On-Chain Metadata
Off-Chain Metadata
The contract supports off-chain metadata through IPFS or centralized storage:Access Control
Roles
The contract implements role-based access control with the following roles:Permission Matrix
| Operation | MINTER_ROLE | ADMIN_ROLE | METADATA_ROLE | Token Owner |
|---|---|---|---|---|
| Mint Identity | ✅ | ✅ | ❌ | ❌ |
| Activate Identity | ❌ | ❌ | ❌ | ✅ |
| Update Metadata | ❌ | ✅ | ✅ | ❌ |
| Grant Roles | ❌ | ✅ | ❌ | ❌ |
| Transfer (before activation) | ❌ | ❌ | ❌ | ✅ |
| Transfer (after activation) | ❌ | ❌ | ❌ | ❌ |
Gas Optimization
Storage Patterns
The contract uses efficient storage patterns to minimize gas costs:Gas Estimates
| Operation | Gas Cost | Description |
|---|---|---|
| Mint Identity | ~150,000 | Create new identity with metadata |
| Activate Identity | ~50,000 | Make token soulbound |
| Transfer (before activation) | ~80,000 | Standard ERC-721 transfer |
| Transfer (after activation) | ❌ | Reverts - token is soulbound |
| Update Metadata | ~30,000 | Update token URI |
| Query Operations | ~2,000-5,000 | View functions |
Contract Verification
Etherscan Verification
The contract is verified on Etherscan for transparency and security:Source Code
The contract source code is available on GitHub:Integration Examples
Basic Contract Interaction
Event Listening
Security Considerations
Audit Results
The Identity SBT contract has undergone comprehensive security audits:- Audit Firm: ConsenSys Diligence
- Audit Date: January 2024
- Severity: No critical or high-severity issues found
- Report: Available here
Security Features
- Reentrancy Protection: All external calls are protected
- Access Control: Role-based permissions prevent unauthorized access
- Input Validation: All inputs are validated before processing
- Gas Limit Protection: Functions have reasonable gas limits
- Upgrade Safety: Core logic is immutable, only parameters are configurable
Known Limitations
- Metadata Immutability: Once set, metadata cannot be changed
- Transfer Irreversibility: Once activated, tokens cannot be transferred
- Gas Costs: Complex operations may have higher gas costs
- Network Dependency: Contract behavior depends on network state
Best Practices
For Developers
- Always Check Activation Status: Verify if a token is activated before attempting transfers
- Handle Events Properly: Listen for events to track state changes
- Validate Inputs: Ensure all inputs are valid before calling contract functions
- Use Proper Error Handling: Implement comprehensive error handling for all operations
For Users
- Understand Soulbound Nature: Once activated, tokens cannot be transferred
- Verify Metadata: Check token metadata before activation
- Secure Private Keys: Keep private keys secure as tokens cannot be recovered
- Test on Testnet: Always test operations on testnet before mainnet
Related Documentation
- Functions Reference - Complete function documentation
- Events Reference - Event documentation
- Integration Guide - Integration examples
- Security Guide - Security considerations
- Deployment Guide - Deployment instructions