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.
Overview
ZKScore supports multiple blockchain networks, allowing users to maintain their reputation and identity across different chains.
Supported Networks
Mainnet Networks
- Ethereum: Primary network with full feature support
- Polygon: Layer 2 scaling solution
- Arbitrum: Optimistic rollup
- Base: Coinbase Layer 2
Testnet Networks
- Goerli: Ethereum testnet
- Mumbai: Polygon testnet
- Arbitrum Goerli: Arbitrum testnet
Cross-Chain Identity
Identity Portability
ZKScore identities are portable across all supported networks:
// Identity works across all networks
const identity = await client.getIdentity('alice.zks');
console.log('ZKS ID:', identity.zksId);
console.log('Network:', identity.network);
console.log('Cross-chain enabled:', identity.crossChain);
Network-Specific Operations
// Switch networks
const ethereumClient = new ZKScoreClient({
apiKey: 'your_api_key',
network: 'ethereum'
});
const polygonClient = new ZKScoreClient({
apiKey: 'your_api_key',
network: 'polygon'
});
// Get score on specific network
const ethereumScore = await ethereumClient.getScore('alice.zks');
const polygonScore = await polygonClient.getScore('alice.zks');
Cross-Chain Score Aggregation
Multi-Chain Scores
// Get aggregated score across all networks
const aggregatedScore = await client.getAggregatedScore('alice.zks');
console.log('Aggregated score:', aggregatedScore.total);
// Get network-specific scores
const networkScores = await client.getNetworkScores('alice.zks');
console.log('Ethereum score:', networkScores.ethereum);
console.log('Polygon score:', networkScores.polygon);
Score Synchronization
// Sync scores across networks
const syncResult = await client.syncScoresAcrossNetworks('alice.zks');
console.log('Sync result:', syncResult);
// Check sync status
const syncStatus = await client.getSyncStatus('alice.zks');
console.log('Sync status:', syncStatus);
Network Configuration
Client Configuration
// Multi-network client
const client = new ZKScoreClient({
apiKey: 'your_api_key',
networks: {
ethereum: {
rpc: 'https://eth-mainnet.alchemyapi.io/v2/YOUR_KEY',
chainId: 1
},
polygon: {
rpc: 'https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY',
chainId: 137
},
arbitrum: {
rpc: 'https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY',
chainId: 42161
}
}
});
Network Switching
// Switch active network
await client.switchNetwork('polygon');
// Get current network
const currentNetwork = client.getCurrentNetwork();
console.log('Current network:', currentNetwork);
// Check network support
const isSupported = client.isNetworkSupported('base');
console.log('Base supported:', isSupported);
Cross-Chain Attestations
Attestation Portability
// Create attestation on specific network
const attestation = await client.createAttestation({
recipient: 'alice.zks',
schema: 'skill_verification',
data: { skill: 'Solidity', level: 8 },
network: 'ethereum'
});
// Verify attestation across networks
const isValid = await client.verifyAttestation(attestation.id, 'polygon');
console.log('Valid on Polygon:', isValid);
Cross-Chain Verification
// Get attestations from all networks
const allAttestations = await client.getCrossChainAttestations('alice.zks');
console.log('Total attestations:', allAttestations.length);
// Filter by network
const ethereumAttestations = allAttestations.filter(
att => att.network === 'ethereum'
);
Gas Optimization
Network Selection
// Get gas prices across networks
const gasPrices = await client.getGasPrices();
console.log('Gas prices:', gasPrices);
// Select optimal network for transaction
const optimalNetwork = client.selectOptimalNetwork({
transactionType: 'mint_identity',
urgency: 'low'
});
console.log('Optimal network:', optimalNetwork);
Batch Operations
// Batch operations across networks
const batchResult = await client.batchOperations([
{
operation: 'getScore',
network: 'ethereum',
params: ['alice.zks']
},
{
operation: 'getScore',
network: 'polygon',
params: ['alice.zks']
}
]);
React Multi-Chain Integration
Network Provider
import React, { createContext, useContext, useState } from 'react';
import { ZKScoreClient } from '@zkscore/sdk';
const NetworkContext = createContext();
export const NetworkProvider = ({ children }) => {
const [currentNetwork, setCurrentNetwork] = useState('ethereum');
const [client, setClient] = useState(null);
useEffect(() => {
const zkClient = new ZKScoreClient({
apiKey: process.env.REACT_APP_ZKSCORE_API_KEY,
network: currentNetwork
});
setClient(zkClient);
}, [currentNetwork]);
const switchNetwork = (network) => {
setCurrentNetwork(network);
};
return (
<NetworkContext.Provider value={{
currentNetwork,
client,
switchNetwork
}}>
{children}
</NetworkContext.Provider>
);
};
export const useNetwork = () => useContext(NetworkContext);
Network Selector Component
const NetworkSelector = () => {
const { currentNetwork, switchNetwork } = useNetwork();
const networks = [
{ id: 'ethereum', name: 'Ethereum', icon: '⟠' },
{ id: 'polygon', name: 'Polygon', icon: '⬟' },
{ id: 'arbitrum', name: 'Arbitrum', icon: '🔷' },
{ id: 'base', name: 'Base', icon: '🔵' }
];
return (
<div className="network-selector">
<label>Network:</label>
<select
value={currentNetwork}
onChange={(e) => switchNetwork(e.target.value)}
>
{networks.map(network => (
<option key={network.id} value={network.id}>
{network.icon} {network.name}
</option>
))}
</select>
</div>
);
};
Best Practices
Network Selection
- Gas Costs: Consider gas costs when choosing networks
- Speed: Use faster networks for time-sensitive operations
- Security: Use more secure networks for high-value operations
- Compatibility: Ensure your application supports the chosen network
Cross-Chain Operations
- Synchronization: Regularly sync data across networks
- Consistency: Maintain consistent data across all networks
- Error Handling: Handle network-specific errors gracefully
- Fallbacks: Provide fallback options for network failures