Copy async getTokenAnalytics(tokenAddress, network = 'ethereum') {
const alchemy = this.clients[network];
try {
// Get token metadata
const metadata = await alchemy.core.getTokenMetadata(tokenAddress);
// Get token balances for top holders
const topHolders = await alchemy.core.getOwnersForToken(tokenAddress, {
withTokenBalances: true,
pageSize: 100
});
// Get transfer history
const transfers = await alchemy.core.getAssetTransfers({
fromBlock: '0x0',
toBlock: 'latest',
contractAddresses: [tokenAddress],
category: ['erc20'],
withMetadata: true,
excludeZeroValue: true,
maxCount: 1000
});
// Analyze holder distribution
const holderAnalysis = this.analyzeHolderDistribution(topHolders);
return {
token: {
name: metadata.name,
symbol: metadata.symbol,
decimals: metadata.decimals,
totalSupply: metadata.totalSupply
},
holders: {
total: topHolders.totalCount,
distribution: holderAnalysis.distribution,
concentration: holderAnalysis.concentration,
whalePercentage: holderAnalysis.whalePercentage
},
activity: {
totalTransfers: transfers.transfers.length,
uniqueAddresses: this.getUniqueAddresses(transfers.transfers),
avgTransferValue: this.calculateAvgTransferValue(transfers.transfers),
recentActivity: this.getRecentActivity(transfers.transfers)
}
};
} catch (error) {
throw new Error(`Alchemy token analysis failed: ${error.message}`);
}
}
async getContractSecurity(contractAddress, network = 'ethereum') {
const alchemy = this.clients[network];
// Get contract code
const code = await alchemy.core.getCode(contractAddress);
// Get contract creation transaction
const creationTx = await this.getContractCreation(contractAddress, alchemy);
// Analyze contract functions
const functions = await this.analyzeContractFunctions(contractAddress, alchemy);
return {
hasCode: code !== '0x',
codeSize: code.length,
creator: creationTx?.from,
creationBlock: creationTx?.blockNumber,
creationTime: creationTx?.timestamp,
isVerified: await this.checkVerificationStatus(contractAddress),
functions: functions,
securityFlags: this.identifySecurityConcerns(functions)
};
}