clanker-sdk 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,11 +24,14 @@ Create a `.env` file in your project root:
|
|
|
24
24
|
# Clanker API Key (required for token operations)
|
|
25
25
|
CLANKER_API_KEY=your_api_key_here
|
|
26
26
|
|
|
27
|
-
# Dune Analytics API Key (
|
|
27
|
+
# Dune Analytics API Key (optional)
|
|
28
28
|
DUNE_API_KEY=your_dune_api_key_here
|
|
29
29
|
|
|
30
|
-
# The Graph API Key (optional
|
|
30
|
+
# The Graph API Key (optional)
|
|
31
31
|
GRAPH_API_KEY=your_graph_api_key_here
|
|
32
|
+
|
|
33
|
+
# CoinGecko Pro API Key (optional)
|
|
34
|
+
COINGECKO_API_KEY=your_coingecko_api_key_here
|
|
32
35
|
```
|
|
33
36
|
|
|
34
37
|
Copy the `.env.example` file to get started:
|
|
@@ -41,7 +44,10 @@ Make sure to add your API keys to the `.env` file and never commit it to version
|
|
|
41
44
|
|
|
42
45
|
### 3. Getting Your API Keys
|
|
43
46
|
|
|
44
|
-
####
|
|
47
|
+
#### Clanker API Key
|
|
48
|
+
Contact `btayengco` on Telegram or Warpcast to request access.
|
|
49
|
+
|
|
50
|
+
#### Dune Analytics API Key (Optional)
|
|
45
51
|
To access market data features:
|
|
46
52
|
1. Visit [dune.xyz](https://dune.xyz) and sign up for an account
|
|
47
53
|
2. Go to your [API Keys page](https://dune.com/settings/api)
|
|
@@ -57,6 +63,15 @@ To access Uniswap data:
|
|
|
57
63
|
3. Create an API key
|
|
58
64
|
4. Add the key to your `.env` file as `GRAPH_API_KEY`
|
|
59
65
|
|
|
66
|
+
#### CoinGecko Pro API Key (Optional)
|
|
67
|
+
To access CoinGecko's comprehensive market data:
|
|
68
|
+
1. Visit [CoinGecko](https://www.coingecko.com) and create an account
|
|
69
|
+
2. Go to your [Developer Dashboard](https://www.coingecko.com/en/api/pricing)
|
|
70
|
+
3. Choose a subscription plan and create an API key
|
|
71
|
+
4. Add the key to your `.env` file as `COINGECKO_API_KEY`
|
|
72
|
+
|
|
73
|
+
For detailed instructions on setting up your CoinGecko API key, visit their [official documentation](https://docs.coingecko.com/reference/setting-up-your-api-key).
|
|
74
|
+
|
|
60
75
|
### 4. Basic Usage
|
|
61
76
|
|
|
62
77
|
```typescript
|
|
@@ -66,25 +81,55 @@ import { ClankerSDK, MarketDataClient } from 'clanker-sdk';
|
|
|
66
81
|
// Load environment variables
|
|
67
82
|
dotenv.config();
|
|
68
83
|
|
|
69
|
-
// Initialize
|
|
70
|
-
const clanker = new ClankerSDK(process.env.CLANKER_API_KEY);
|
|
71
|
-
|
|
72
|
-
// Initialize market data client with both Dune and Graph API keys
|
|
84
|
+
// Initialize market data client (CoinGecko API key required for token prices)
|
|
73
85
|
const marketData = new MarketDataClient(
|
|
74
|
-
process.env.DUNE_API_KEY,
|
|
75
|
-
process.env.GRAPH_API_KEY
|
|
86
|
+
process.env.DUNE_API_KEY, // Optional: For Dune Analytics data
|
|
87
|
+
process.env.GRAPH_API_KEY, // Optional: For Uniswap data
|
|
88
|
+
process.env.COINGECKO_API_KEY // Required for token price lookups
|
|
76
89
|
);
|
|
77
90
|
|
|
91
|
+
// Example 1: Get price for your token on Base/Ethereum
|
|
92
|
+
const tokenAddress = '0x1234567890123456789012345678901234567890'; // Your token address
|
|
93
|
+
|
|
94
|
+
// Direct CoinGecko API usage
|
|
95
|
+
const url = 'https://pro-api.coingecko.com/api/v3/simple/token_price/id';
|
|
96
|
+
const options = {
|
|
97
|
+
method: 'GET',
|
|
98
|
+
headers: {
|
|
99
|
+
'accept': 'application/json',
|
|
100
|
+
'x-cg-pro-api-key': process.env.COINGECKO_API_KEY
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// You can use the API directly
|
|
105
|
+
fetch(url, options)
|
|
106
|
+
.then(res => res.json())
|
|
107
|
+
.then(json => console.log('Token price:', json))
|
|
108
|
+
.catch(err => console.error('Error:', err));
|
|
109
|
+
|
|
110
|
+
// Or use our SDK wrapper for easier handling
|
|
111
|
+
const tokenPrices = await marketData.getGeckoTokenPrice({
|
|
112
|
+
'ethereum': [tokenAddress] // For tokens on Base/Ethereum
|
|
113
|
+
});
|
|
114
|
+
console.log('Token prices:', tokenPrices);
|
|
115
|
+
|
|
116
|
+
// Example 2: Other SDK features (optional)
|
|
117
|
+
const clanker = new ClankerSDK(process.env.CLANKER_API_KEY);
|
|
118
|
+
|
|
78
119
|
// Deploy a token
|
|
79
120
|
const token = await clanker.deployToken({
|
|
80
121
|
name: "Community Token",
|
|
81
122
|
symbol: "CMTY",
|
|
82
123
|
image: "https://example.com/token.png",
|
|
83
|
-
requestorAddress: "0x1234567890123456789012345678901234567890"
|
|
124
|
+
requestorAddress: "0x1234567890123456789012345678901234567890"
|
|
84
125
|
});
|
|
85
126
|
|
|
86
|
-
// Get market data
|
|
87
|
-
const
|
|
127
|
+
// Get additional market data
|
|
128
|
+
const additionalData = await Promise.all([
|
|
129
|
+
marketData.getClankerDictionary(),
|
|
130
|
+
marketData.getDexPairStats('ethereum', token.contractAddress),
|
|
131
|
+
marketData.getUniswapData([token.contractAddress])
|
|
132
|
+
]);
|
|
88
133
|
```
|
|
89
134
|
|
|
90
135
|
## Features
|
|
@@ -100,6 +145,39 @@ const marketStats = await marketData.getClankerDictionary();
|
|
|
100
145
|
|
|
101
146
|
The SDK provides access to comprehensive market data through multiple sources:
|
|
102
147
|
|
|
148
|
+
### CoinGecko Market Data
|
|
149
|
+
Get token prices by contract address on Base/Ethereum:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Example 1: Get price for your token (RECOMMENDED)
|
|
153
|
+
const tokenAddress = '0x1234567890123456789012345678901234567890'; // Your token address
|
|
154
|
+
|
|
155
|
+
// The SDK uses this CoinGecko endpoint under the hood:
|
|
156
|
+
// GET https://pro-api.coingecko.com/api/v3/simple/token_price/id
|
|
157
|
+
// You can also use it directly:
|
|
158
|
+
const url = 'https://pro-api.coingecko.com/api/v3/simple/token_price/id';
|
|
159
|
+
const options = {
|
|
160
|
+
method: 'GET',
|
|
161
|
+
headers: {
|
|
162
|
+
'accept': 'application/json',
|
|
163
|
+
'x-cg-pro-api-key': process.env.COINGECKO_API_KEY
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Direct API usage
|
|
168
|
+
fetch(url, options)
|
|
169
|
+
.then(res => res.json())
|
|
170
|
+
.then(json => console.log(json))
|
|
171
|
+
.catch(err => console.error(err));
|
|
172
|
+
|
|
173
|
+
// Or use our SDK wrapper (handles authentication and error handling)
|
|
174
|
+
const tokenPrices = await marketData.getGeckoTokenPrice({
|
|
175
|
+
'ethereum': [tokenAddress] // For tokens on Base/Ethereum
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This endpoint is specifically designed for getting token prices on Base/Ethereum. For other data sources or chains, see below.
|
|
180
|
+
|
|
103
181
|
### Clanker Dictionary
|
|
104
182
|
Get detailed information about all Clanker tokens:
|
|
105
183
|
```typescript
|