Skip to content

Instantly share code, notes, and snippets.

@peterpeterparker
Last active October 20, 2024 08:28
Show Gist options
  • Save peterpeterparker/bd58df85d405012eaa5db97bff6d015b to your computer and use it in GitHub Desktop.
Save peterpeterparker/bd58df85d405012eaa5db97bff6d015b to your computer and use it in GitHub Desktop.
List of token symbols of length
// Relates to https://ethereum.stackexchange.com/questions/25619/is-there-length-limits-on-token-symbols?newreg=787e203d2b4c49cd8caecc1434ef435b
//
// Data source: Coingecko public API.
// Jul. 4th 2024
//
// Coin symbols of length 0: 7
// Coin symbols of length 1: 39
// Coin symbols of length 2: 353
// Coin symbols of length 3: 4339
// Coin symbols of length 4: 5025
// Coin symbols of length 5: 2640
// Coin symbols of length 6: 1370
// Coin symbols of length 7: 517
// Coin symbols of length 8: 300
// Coin symbols of length 9: 138
// Coin symbols of length 10: 81
// Coin symbols of length 11: 21
// Coin symbols of length 12: 9
// Coin symbols of length 13: 8
// Coin symbols of length 14: 12
// Coin symbols of length 15: 6
// Coin symbols of length 16: 1
// Coin symbols of length 17: 1
// Coin symbols of length 18: 2
// Script
#!/usr/bin/env node
const COINGECKO_API_URL = 'https://api.coingecko.com/api/v3';
const fetchCoingecko = async () => {
const response = await fetch(`${COINGECKO_API_URL}/coins/list`);
if (!response.ok) {
throw new Error('Goincecko API response not ok.');
}
return response.json();
};
const data = await fetchCoingecko();
const symbols = Object.groupBy(data, ({ symbol }) => symbol.length);
Object.entries(symbols).forEach(([key, tokens]) =>
console.log(`Coin symbols of length ${key}: ${tokens.length}`)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment