clanker-sdk 1.6.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 +62 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,36 +81,53 @@ import { ClankerSDK, MarketDataClient } from 'clanker-sdk';
|
|
|
81
81
|
// Load environment variables
|
|
82
82
|
dotenv.config();
|
|
83
83
|
|
|
84
|
-
// Initialize
|
|
85
|
-
const clanker = new ClankerSDK(process.env.CLANKER_API_KEY);
|
|
86
|
-
|
|
87
|
-
// Initialize market data client with desired API keys
|
|
84
|
+
// Initialize market data client (CoinGecko API key required for token prices)
|
|
88
85
|
const marketData = new MarketDataClient(
|
|
89
86
|
process.env.DUNE_API_KEY, // Optional: For Dune Analytics data
|
|
90
87
|
process.env.GRAPH_API_KEY, // Optional: For Uniswap data
|
|
91
|
-
process.env.COINGECKO_API_KEY //
|
|
88
|
+
process.env.COINGECKO_API_KEY // Required for token price lookups
|
|
92
89
|
);
|
|
93
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
|
+
|
|
94
119
|
// Deploy a token
|
|
95
120
|
const token = await clanker.deployToken({
|
|
96
121
|
name: "Community Token",
|
|
97
122
|
symbol: "CMTY",
|
|
98
123
|
image: "https://example.com/token.png",
|
|
99
|
-
requestorAddress: "0x1234567890123456789012345678901234567890"
|
|
124
|
+
requestorAddress: "0x1234567890123456789012345678901234567890"
|
|
100
125
|
});
|
|
101
126
|
|
|
102
|
-
// Get market data
|
|
103
|
-
const
|
|
104
|
-
// Get CoinGecko market data
|
|
105
|
-
marketData.getGeckoTokenData(['bitcoin', 'ethereum']),
|
|
106
|
-
|
|
107
|
-
// Get Clanker dictionary data
|
|
127
|
+
// Get additional market data
|
|
128
|
+
const additionalData = await Promise.all([
|
|
108
129
|
marketData.getClankerDictionary(),
|
|
109
|
-
|
|
110
|
-
// Get DEX pair stats
|
|
111
130
|
marketData.getDexPairStats('ethereum', token.contractAddress),
|
|
112
|
-
|
|
113
|
-
// Get Uniswap data
|
|
114
131
|
marketData.getUniswapData([token.contractAddress])
|
|
115
132
|
]);
|
|
116
133
|
```
|
|
@@ -129,17 +146,38 @@ const marketStats = await Promise.all([
|
|
|
129
146
|
The SDK provides access to comprehensive market data through multiple sources:
|
|
130
147
|
|
|
131
148
|
### CoinGecko Market Data
|
|
132
|
-
Get
|
|
149
|
+
Get token prices by contract address on Base/Ethereum:
|
|
150
|
+
|
|
133
151
|
```typescript
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
//
|
|
138
|
-
// -
|
|
139
|
-
//
|
|
140
|
-
|
|
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
|
+
});
|
|
141
177
|
```
|
|
142
178
|
|
|
179
|
+
This endpoint is specifically designed for getting token prices on Base/Ethereum. For other data sources or chains, see below.
|
|
180
|
+
|
|
143
181
|
### Clanker Dictionary
|
|
144
182
|
Get detailed information about all Clanker tokens:
|
|
145
183
|
```typescript
|