@clawnch/clawncher-sdk 0.1.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 +603 -0
- package/dist/abis.d.ts +935 -0
- package/dist/abis.d.ts.map +1 -0
- package/dist/abis.js +486 -0
- package/dist/abis.js.map +1 -0
- package/dist/addresses.d.ts +51 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +80 -0
- package/dist/addresses.js.map +1 -0
- package/dist/api-deployer-types.d.ts +165 -0
- package/dist/api-deployer-types.d.ts.map +1 -0
- package/dist/api-deployer-types.js +9 -0
- package/dist/api-deployer-types.js.map +1 -0
- package/dist/api-deployer.d.ts +114 -0
- package/dist/api-deployer.d.ts.map +1 -0
- package/dist/api-deployer.js +309 -0
- package/dist/api-deployer.js.map +1 -0
- package/dist/claimer.d.ts +197 -0
- package/dist/claimer.d.ts.map +1 -0
- package/dist/claimer.js +311 -0
- package/dist/claimer.js.map +1 -0
- package/dist/deployer.d.ts +229 -0
- package/dist/deployer.d.ts.map +1 -0
- package/dist/deployer.js +305 -0
- package/dist/deployer.js.map +1 -0
- package/dist/erc8004-types.d.ts +94 -0
- package/dist/erc8004-types.d.ts.map +1 -0
- package/dist/erc8004-types.js +8 -0
- package/dist/erc8004-types.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +75 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +358 -0
- package/dist/index.js.map +1 -0
- package/dist/liquidity-types.d.ts +198 -0
- package/dist/liquidity-types.d.ts.map +1 -0
- package/dist/liquidity-types.js +8 -0
- package/dist/liquidity-types.js.map +1 -0
- package/dist/liquidity.d.ts +111 -0
- package/dist/liquidity.d.ts.map +1 -0
- package/dist/liquidity.js +608 -0
- package/dist/liquidity.js.map +1 -0
- package/dist/molten-types.d.ts +282 -0
- package/dist/molten-types.d.ts.map +1 -0
- package/dist/molten-types.js +8 -0
- package/dist/molten-types.js.map +1 -0
- package/dist/molten.d.ts +336 -0
- package/dist/molten.d.ts.map +1 -0
- package/dist/molten.js +560 -0
- package/dist/molten.js.map +1 -0
- package/dist/portfolio.d.ts +129 -0
- package/dist/portfolio.d.ts.map +1 -0
- package/dist/portfolio.js +218 -0
- package/dist/portfolio.js.map +1 -0
- package/dist/reader.d.ts +249 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +488 -0
- package/dist/reader.js.map +1 -0
- package/dist/swap-types.d.ts +159 -0
- package/dist/swap-types.d.ts.map +1 -0
- package/dist/swap-types.js +22 -0
- package/dist/swap-types.js.map +1 -0
- package/dist/swap.d.ts +762 -0
- package/dist/swap.d.ts.map +1 -0
- package/dist/swap.js +345 -0
- package/dist/swap.js.map +1 -0
- package/dist/token-verification-data.d.ts +4 -0
- package/dist/token-verification-data.d.ts.map +1 -0
- package/dist/token-verification-data.js +6 -0
- package/dist/token-verification-data.js.map +1 -0
- package/dist/types.d.ts +244 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/uniswap-abis.d.ts +470 -0
- package/dist/uniswap-abis.d.ts.map +1 -0
- package/dist/uniswap-abis.js +322 -0
- package/dist/uniswap-abis.js.map +1 -0
- package/dist/uniswap-addresses.d.ts +38 -0
- package/dist/uniswap-addresses.d.ts.map +1 -0
- package/dist/uniswap-addresses.js +67 -0
- package/dist/uniswap-addresses.js.map +1 -0
- package/dist/vanity.d.ts +115 -0
- package/dist/vanity.d.ts.map +1 -0
- package/dist/vanity.js +166 -0
- package/dist/vanity.js.map +1 -0
- package/dist/verify.d.ts +88 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +181 -0
- package/dist/verify.js.map +1 -0
- package/dist/watcher.d.ts +112 -0
- package/dist/watcher.d.ts.map +1 -0
- package/dist/watcher.js +132 -0
- package/dist/watcher.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawnchDeployer - Token deployment via Clanker's approved Uniswap V4 infrastructure
|
|
3
|
+
*
|
|
4
|
+
* v3: Wraps clanker-sdk/v4 internally while maintaining the Clawncher API.
|
|
5
|
+
* Tokens deployed through this SDK are immediately tradeable on Uniswap.
|
|
6
|
+
*
|
|
7
|
+
* Fee structure (Clanker infrastructure):
|
|
8
|
+
* - 1% LP fee per swap
|
|
9
|
+
* - 80% to reward recipients (configurable)
|
|
10
|
+
* - 20% protocol (Clanker)
|
|
11
|
+
*/
|
|
12
|
+
import { type WalletClient, type PublicClient, type Chain, type Account, type Transport, type Hash, type Address } from 'viem';
|
|
13
|
+
import { type NetworkName } from './addresses.js';
|
|
14
|
+
/**
|
|
15
|
+
* Fee preference for reward recipients
|
|
16
|
+
*/
|
|
17
|
+
export type FeePreference = 'Clawnch' | 'Paired' | 'Both';
|
|
18
|
+
/**
|
|
19
|
+
* Reward recipient configuration
|
|
20
|
+
*/
|
|
21
|
+
export interface RewardRecipient {
|
|
22
|
+
recipient: Address;
|
|
23
|
+
admin: Address;
|
|
24
|
+
/** Basis points (100 = 1%, max 10000 = 100%) */
|
|
25
|
+
bps: number;
|
|
26
|
+
/** Which token to receive fees in (default: 'Clawnch' = the launched token) */
|
|
27
|
+
feePreference?: FeePreference;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Vault configuration (optional)
|
|
31
|
+
*/
|
|
32
|
+
export interface VaultConfig {
|
|
33
|
+
/** Percentage of token supply for vault (1-90%) */
|
|
34
|
+
percentage: number;
|
|
35
|
+
/** Lockup duration in seconds (minimum 7 days = 604800) */
|
|
36
|
+
lockupDuration: number;
|
|
37
|
+
/** Vesting duration in seconds after lockup (0 = instant unlock after lockup) */
|
|
38
|
+
vestingDuration?: number;
|
|
39
|
+
/** Recipient who can claim after lockup */
|
|
40
|
+
recipient: Address;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* AirdropV2 configuration (optional)
|
|
44
|
+
*/
|
|
45
|
+
export interface AirdropConfig {
|
|
46
|
+
/** Percentage of token supply for airdrop (1-90%) */
|
|
47
|
+
percentage: number;
|
|
48
|
+
/** Admin who can update merkle root */
|
|
49
|
+
admin: Address;
|
|
50
|
+
/** Merkle root for claims (can be bytes32(0) initially) */
|
|
51
|
+
merkleRoot: `0x${string}`;
|
|
52
|
+
/** Lockup duration in seconds (minimum 1 day) */
|
|
53
|
+
lockupDuration: number;
|
|
54
|
+
/** Vesting duration in seconds (0 = instant) */
|
|
55
|
+
vestingDuration: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* DevBuy configuration (optional - buy tokens at launch with ETH)
|
|
59
|
+
* Tokens are transferred immediately to recipient (no vesting)
|
|
60
|
+
*/
|
|
61
|
+
export interface DevBuyConfig {
|
|
62
|
+
/** ETH amount to spend on dev buy */
|
|
63
|
+
ethAmount: bigint;
|
|
64
|
+
/** Recipient of purchased tokens */
|
|
65
|
+
recipient: Address;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Token metadata
|
|
69
|
+
*/
|
|
70
|
+
export interface TokenMetadata {
|
|
71
|
+
description?: string;
|
|
72
|
+
socialMediaUrls?: Array<{
|
|
73
|
+
platform: string;
|
|
74
|
+
url: string;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Token context
|
|
79
|
+
*/
|
|
80
|
+
export interface TokenContext {
|
|
81
|
+
interface?: string;
|
|
82
|
+
platform?: string;
|
|
83
|
+
messageId?: string;
|
|
84
|
+
id?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Token deployment options
|
|
88
|
+
*/
|
|
89
|
+
export interface DeployOptions {
|
|
90
|
+
name: string;
|
|
91
|
+
symbol: string;
|
|
92
|
+
/** Address that can update token metadata */
|
|
93
|
+
tokenAdmin: Address;
|
|
94
|
+
/** Image URL for token */
|
|
95
|
+
image?: string;
|
|
96
|
+
/** Token metadata (description, social links) */
|
|
97
|
+
metadata?: TokenMetadata;
|
|
98
|
+
/** Deployment context */
|
|
99
|
+
context?: TokenContext;
|
|
100
|
+
/** Reward configuration (who receives LP fees) */
|
|
101
|
+
rewards: {
|
|
102
|
+
recipients: RewardRecipient[];
|
|
103
|
+
};
|
|
104
|
+
/** Optional vault allocation */
|
|
105
|
+
vault?: VaultConfig;
|
|
106
|
+
/** Optional airdrop allocation */
|
|
107
|
+
airdrop?: AirdropConfig;
|
|
108
|
+
/** Optional dev buy at launch (instant transfer) */
|
|
109
|
+
devBuy?: DevBuyConfig;
|
|
110
|
+
/**
|
|
111
|
+
* Enable vanity address (default: true)
|
|
112
|
+
* Uses Clanker's remote vanity service (produces "b07" suffix)
|
|
113
|
+
*/
|
|
114
|
+
vanity?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Simulate deployment without sending transaction.
|
|
117
|
+
* Returns validation result and translated config.
|
|
118
|
+
*/
|
|
119
|
+
dryRun?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Deployment result
|
|
123
|
+
*/
|
|
124
|
+
export interface DeployResult {
|
|
125
|
+
/** Transaction hash (undefined if error or dry run) */
|
|
126
|
+
txHash: Hash | undefined;
|
|
127
|
+
/** Wait for transaction and get token address */
|
|
128
|
+
waitForTransaction: () => Promise<{
|
|
129
|
+
address: Address | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
/** Error if deployment failed */
|
|
132
|
+
error: Error | undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Dry run result (returned when dryRun: true)
|
|
136
|
+
*/
|
|
137
|
+
export interface DryRunResult extends DeployResult {
|
|
138
|
+
/** The translated Clanker config (for inspection) */
|
|
139
|
+
translatedConfig: Record<string, unknown>;
|
|
140
|
+
/** Validation passed */
|
|
141
|
+
valid: boolean;
|
|
142
|
+
/** Estimated gas (if publicClient available) */
|
|
143
|
+
estimatedGas?: bigint;
|
|
144
|
+
/** Estimated gas cost in ETH (if gas price available) */
|
|
145
|
+
estimatedCostEth?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Deployer configuration
|
|
149
|
+
*/
|
|
150
|
+
export interface DeployerConfig {
|
|
151
|
+
/** Wallet client for signing transactions */
|
|
152
|
+
wallet?: WalletClient<Transport, Chain, Account>;
|
|
153
|
+
/** Public client for reading chain data */
|
|
154
|
+
publicClient?: PublicClient;
|
|
155
|
+
/** Network to deploy on (default: 'mainnet') */
|
|
156
|
+
network?: NetworkName;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* ClawnchDeployer - Deploy tokens on Base with Uniswap V4 pools
|
|
160
|
+
*
|
|
161
|
+
* v3: Deploys through Clanker's approved infrastructure for immediate
|
|
162
|
+
* Uniswap tradability. Same API as v2.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* import { ClawnchDeployer } from '@clawnch/clawncher-sdk';
|
|
167
|
+
* import { createWalletClient, createPublicClient, http } from 'viem';
|
|
168
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
169
|
+
* import { base } from 'viem/chains';
|
|
170
|
+
*
|
|
171
|
+
* const account = privateKeyToAccount('0x...');
|
|
172
|
+
* const wallet = createWalletClient({
|
|
173
|
+
* account,
|
|
174
|
+
* chain: base,
|
|
175
|
+
* transport: http(),
|
|
176
|
+
* });
|
|
177
|
+
* const publicClient = createPublicClient({
|
|
178
|
+
* chain: base,
|
|
179
|
+
* transport: http(),
|
|
180
|
+
* });
|
|
181
|
+
*
|
|
182
|
+
* const deployer = new ClawnchDeployer({
|
|
183
|
+
* wallet,
|
|
184
|
+
* publicClient,
|
|
185
|
+
* network: 'mainnet',
|
|
186
|
+
* });
|
|
187
|
+
*
|
|
188
|
+
* const result = await deployer.deploy({
|
|
189
|
+
* name: 'My Token',
|
|
190
|
+
* symbol: 'MYTKN',
|
|
191
|
+
* tokenAdmin: account.address,
|
|
192
|
+
* rewards: {
|
|
193
|
+
* recipients: [{
|
|
194
|
+
* recipient: account.address,
|
|
195
|
+
* admin: account.address,
|
|
196
|
+
* bps: 10000,
|
|
197
|
+
* feePreference: 'Paired',
|
|
198
|
+
* }],
|
|
199
|
+
* },
|
|
200
|
+
* });
|
|
201
|
+
*
|
|
202
|
+
* const { address } = await result.waitForTransaction();
|
|
203
|
+
* console.log('Token deployed:', address);
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export declare class ClawnchDeployer {
|
|
207
|
+
private readonly clanker;
|
|
208
|
+
readonly wallet?: WalletClient<Transport, Chain, Account>;
|
|
209
|
+
readonly publicClient?: PublicClient;
|
|
210
|
+
readonly network: NetworkName;
|
|
211
|
+
constructor(config: DeployerConfig);
|
|
212
|
+
/**
|
|
213
|
+
* Get contract addresses for configured network
|
|
214
|
+
*/
|
|
215
|
+
getAddresses(): import("./addresses.js").NetworkAddresses;
|
|
216
|
+
/**
|
|
217
|
+
* Get the chain for the configured network
|
|
218
|
+
*/
|
|
219
|
+
getChain(): Chain;
|
|
220
|
+
/**
|
|
221
|
+
* Check if deployer is properly configured
|
|
222
|
+
*/
|
|
223
|
+
isConfigured(): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Deploy a new token
|
|
226
|
+
*/
|
|
227
|
+
deploy(options: DeployOptions): Promise<DeployResult>;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=deployer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,OAAO,EAEb,MAAM,MAAM,CAAC;AAId,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,gB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C,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,MAAM,CAAC,EAAE,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,2CAA2C;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gDAAgD;IAChD,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;gBAElB,MAAM,EAAE,cAAc;IAYlC;;OAEG;IACH,YAAY;IAIZ;;OAEG;IACH,QAAQ,IAAI,KAAK;IAIjB;;OAEG;IACH,YAAY,IAAI,OAAO;IASvB;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA6L5D"}
|
package/dist/deployer.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawnchDeployer - Token deployment via Clanker's approved Uniswap V4 infrastructure
|
|
3
|
+
*
|
|
4
|
+
* v3: Wraps clanker-sdk/v4 internally while maintaining the Clawncher API.
|
|
5
|
+
* Tokens deployed through this SDK are immediately tradeable on Uniswap.
|
|
6
|
+
*
|
|
7
|
+
* Fee structure (Clanker infrastructure):
|
|
8
|
+
* - 1% LP fee per swap
|
|
9
|
+
* - 80% to reward recipients (configurable)
|
|
10
|
+
* - 20% protocol (Clanker)
|
|
11
|
+
*/
|
|
12
|
+
import { formatEther, } from 'viem';
|
|
13
|
+
import { Clanker } from 'clanker-sdk/v4';
|
|
14
|
+
import { POOL_POSITIONS } from 'clanker-sdk';
|
|
15
|
+
import { base, baseSepolia } from 'viem/chains';
|
|
16
|
+
import { getAddresses, getChainId } from './addresses.js';
|
|
17
|
+
import { ClawnchErrorCode, ClawnchDeployError } from './errors.js';
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Internal helpers
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/**
|
|
22
|
+
* Translate our fee preference to Clanker's token field
|
|
23
|
+
* Our: 'Clawnch' | 'Paired' | 'Both'
|
|
24
|
+
* Clanker: 'Clanker' | 'Paired' | 'Both'
|
|
25
|
+
*/
|
|
26
|
+
function translateFeePreference(pref) {
|
|
27
|
+
switch (pref) {
|
|
28
|
+
case 'Clawnch': return 'Clanker';
|
|
29
|
+
case 'Paired': return 'Paired';
|
|
30
|
+
case 'Both': return 'Both';
|
|
31
|
+
default: return 'Clanker'; // default: receive fees in the launched token
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function errorResult(code, message, cause) {
|
|
35
|
+
return {
|
|
36
|
+
txHash: undefined,
|
|
37
|
+
waitForTransaction: async () => ({ address: undefined }),
|
|
38
|
+
error: new ClawnchDeployError(code, message, cause),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// ClawnchDeployer
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* ClawnchDeployer - Deploy tokens on Base with Uniswap V4 pools
|
|
46
|
+
*
|
|
47
|
+
* v3: Deploys through Clanker's approved infrastructure for immediate
|
|
48
|
+
* Uniswap tradability. Same API as v2.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { ClawnchDeployer } from '@clawnch/clawncher-sdk';
|
|
53
|
+
* import { createWalletClient, createPublicClient, http } from 'viem';
|
|
54
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
55
|
+
* import { base } from 'viem/chains';
|
|
56
|
+
*
|
|
57
|
+
* const account = privateKeyToAccount('0x...');
|
|
58
|
+
* const wallet = createWalletClient({
|
|
59
|
+
* account,
|
|
60
|
+
* chain: base,
|
|
61
|
+
* transport: http(),
|
|
62
|
+
* });
|
|
63
|
+
* const publicClient = createPublicClient({
|
|
64
|
+
* chain: base,
|
|
65
|
+
* transport: http(),
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* const deployer = new ClawnchDeployer({
|
|
69
|
+
* wallet,
|
|
70
|
+
* publicClient,
|
|
71
|
+
* network: 'mainnet',
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* const result = await deployer.deploy({
|
|
75
|
+
* name: 'My Token',
|
|
76
|
+
* symbol: 'MYTKN',
|
|
77
|
+
* tokenAdmin: account.address,
|
|
78
|
+
* rewards: {
|
|
79
|
+
* recipients: [{
|
|
80
|
+
* recipient: account.address,
|
|
81
|
+
* admin: account.address,
|
|
82
|
+
* bps: 10000,
|
|
83
|
+
* feePreference: 'Paired',
|
|
84
|
+
* }],
|
|
85
|
+
* },
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* const { address } = await result.waitForTransaction();
|
|
89
|
+
* console.log('Token deployed:', address);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export class ClawnchDeployer {
|
|
93
|
+
clanker;
|
|
94
|
+
wallet;
|
|
95
|
+
publicClient;
|
|
96
|
+
network;
|
|
97
|
+
constructor(config) {
|
|
98
|
+
this.wallet = config.wallet;
|
|
99
|
+
this.publicClient = config.publicClient;
|
|
100
|
+
this.network = config.network ?? 'mainnet';
|
|
101
|
+
// Initialize Clanker SDK with same clients
|
|
102
|
+
this.clanker = new Clanker({
|
|
103
|
+
wallet: config.wallet,
|
|
104
|
+
publicClient: config.publicClient,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get contract addresses for configured network
|
|
109
|
+
*/
|
|
110
|
+
getAddresses() {
|
|
111
|
+
return getAddresses(this.network);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get the chain for the configured network
|
|
115
|
+
*/
|
|
116
|
+
getChain() {
|
|
117
|
+
return this.network === 'mainnet' ? base : baseSepolia;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if deployer is properly configured
|
|
121
|
+
*/
|
|
122
|
+
isConfigured() {
|
|
123
|
+
const addresses = this.getAddresses();
|
|
124
|
+
return !!(addresses.clawnch.factory &&
|
|
125
|
+
addresses.clawnch.factory !== '0x0000000000000000000000000000000000000000' &&
|
|
126
|
+
this.wallet);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Deploy a new token
|
|
130
|
+
*/
|
|
131
|
+
async deploy(options) {
|
|
132
|
+
if (!this.wallet) {
|
|
133
|
+
return errorResult(ClawnchErrorCode.WALLET_NOT_CONFIGURED, 'Wallet not configured');
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
// ====================================================================
|
|
137
|
+
// 1. Validate inputs
|
|
138
|
+
// ====================================================================
|
|
139
|
+
if (!options.rewards.recipients.length) {
|
|
140
|
+
return errorResult(ClawnchErrorCode.INVALID_BPS, 'At least one reward recipient is required');
|
|
141
|
+
}
|
|
142
|
+
const totalBps = options.rewards.recipients.reduce((sum, r) => sum + r.bps, 0);
|
|
143
|
+
if (totalBps !== 10000) {
|
|
144
|
+
return errorResult(ClawnchErrorCode.INVALID_BPS, `Reward bps must sum to 10000, got ${totalBps}`);
|
|
145
|
+
}
|
|
146
|
+
if (options.vault && (options.vault.percentage < 1 || options.vault.percentage > 90)) {
|
|
147
|
+
return errorResult(ClawnchErrorCode.INVALID_BPS, 'Vault percentage must be between 1 and 90');
|
|
148
|
+
}
|
|
149
|
+
// ====================================================================
|
|
150
|
+
// 2. Build translated Clanker config
|
|
151
|
+
// ====================================================================
|
|
152
|
+
const chainId = getChainId(this.network);
|
|
153
|
+
// Translate reward recipients
|
|
154
|
+
const clankerRewards = {
|
|
155
|
+
recipients: options.rewards.recipients.map(r => ({
|
|
156
|
+
recipient: r.recipient,
|
|
157
|
+
admin: r.admin,
|
|
158
|
+
bps: r.bps,
|
|
159
|
+
token: translateFeePreference(r.feePreference),
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
// Build base config
|
|
163
|
+
const clankerConfig = {
|
|
164
|
+
name: options.name,
|
|
165
|
+
symbol: options.symbol,
|
|
166
|
+
tokenAdmin: options.tokenAdmin,
|
|
167
|
+
chainId,
|
|
168
|
+
vanity: options.vanity !== false, // default true
|
|
169
|
+
rewards: clankerRewards,
|
|
170
|
+
fees: { type: 'static', clankerFee: 100, pairedFee: 100 },
|
|
171
|
+
pool: { positions: POOL_POSITIONS.Standard },
|
|
172
|
+
context: {
|
|
173
|
+
interface: 'Clawncher SDK',
|
|
174
|
+
...(options.context || {}),
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
// Image
|
|
178
|
+
if (options.image) {
|
|
179
|
+
clankerConfig.image = options.image;
|
|
180
|
+
}
|
|
181
|
+
// Metadata
|
|
182
|
+
if (options.metadata) {
|
|
183
|
+
clankerConfig.metadata = {
|
|
184
|
+
description: options.metadata.description,
|
|
185
|
+
socialMediaUrls: options.metadata.socialMediaUrls,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Vault
|
|
189
|
+
if (options.vault && options.vault.percentage > 0) {
|
|
190
|
+
clankerConfig.vault = {
|
|
191
|
+
percentage: options.vault.percentage,
|
|
192
|
+
lockupDuration: options.vault.lockupDuration,
|
|
193
|
+
vestingDuration: options.vault.vestingDuration ?? 0,
|
|
194
|
+
recipient: options.vault.recipient,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
// Airdrop
|
|
198
|
+
if (options.airdrop && options.airdrop.percentage > 0) {
|
|
199
|
+
clankerConfig.airdrop = {
|
|
200
|
+
amount: options.airdrop.percentage, // Clanker uses 'amount' not 'percentage'
|
|
201
|
+
admin: options.airdrop.admin,
|
|
202
|
+
merkleRoot: options.airdrop.merkleRoot,
|
|
203
|
+
lockupDuration: options.airdrop.lockupDuration,
|
|
204
|
+
vestingDuration: options.airdrop.vestingDuration,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
// DevBuy (bigint -> decimal number for Clanker)
|
|
208
|
+
if (options.devBuy && options.devBuy.ethAmount > 0n) {
|
|
209
|
+
clankerConfig.devBuy = {
|
|
210
|
+
ethAmount: Number(formatEther(options.devBuy.ethAmount)),
|
|
211
|
+
recipient: options.devBuy.recipient,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// ====================================================================
|
|
215
|
+
// 3. Dry run: return config without deploying
|
|
216
|
+
// ====================================================================
|
|
217
|
+
if (options.dryRun) {
|
|
218
|
+
const dryResult = {
|
|
219
|
+
txHash: undefined,
|
|
220
|
+
waitForTransaction: async () => ({ address: undefined }),
|
|
221
|
+
error: undefined,
|
|
222
|
+
translatedConfig: clankerConfig,
|
|
223
|
+
valid: true,
|
|
224
|
+
};
|
|
225
|
+
// Attempt gas estimation if publicClient is available
|
|
226
|
+
if (this.publicClient) {
|
|
227
|
+
try {
|
|
228
|
+
const gasPrice = await this.publicClient.getGasPrice();
|
|
229
|
+
// Use a conservative estimate for token deployment (~500k gas)
|
|
230
|
+
// Actual estimation requires simulating the factory call which
|
|
231
|
+
// needs the full deployment config assembled by Clanker SDK
|
|
232
|
+
const estimatedGas = 500000n;
|
|
233
|
+
dryResult.estimatedGas = estimatedGas;
|
|
234
|
+
dryResult.estimatedCostEth = formatEther(gasPrice * estimatedGas);
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Gas estimation failed, return without it
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return dryResult;
|
|
241
|
+
}
|
|
242
|
+
// ====================================================================
|
|
243
|
+
// 4. Deploy via Clanker SDK
|
|
244
|
+
// ====================================================================
|
|
245
|
+
const result = await this.clanker.deploy(clankerConfig);
|
|
246
|
+
// Clanker returns { error } on the result object instead of throwing
|
|
247
|
+
if (result.error) {
|
|
248
|
+
const cause = result.error instanceof Error ? result.error : undefined;
|
|
249
|
+
const errMsg = cause ? cause.message : String(result.error);
|
|
250
|
+
return errorResult(ClawnchErrorCode.DEPLOY_FAILED, errMsg, cause);
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
txHash: result.txHash,
|
|
254
|
+
waitForTransaction: async () => {
|
|
255
|
+
if (!result.waitForTransaction) {
|
|
256
|
+
return { address: undefined };
|
|
257
|
+
}
|
|
258
|
+
// ClankerResult<{ address }> resolves to either:
|
|
259
|
+
// { address: '0x...', error?: undefined } — success
|
|
260
|
+
// { address?: undefined, error: ClankerError } — failure
|
|
261
|
+
const txResult = await result.waitForTransaction();
|
|
262
|
+
if (txResult && typeof txResult === 'object' && 'error' in txResult && txResult.error) {
|
|
263
|
+
const cause = txResult.error instanceof Error ? txResult.error : undefined;
|
|
264
|
+
const msg = cause ? cause.message : String(txResult.error);
|
|
265
|
+
throw new ClawnchDeployError(ClawnchErrorCode.TX_REVERTED, `Transaction failed: ${msg}`, cause);
|
|
266
|
+
}
|
|
267
|
+
if (txResult && typeof txResult === 'object' && 'address' in txResult) {
|
|
268
|
+
return { address: txResult.address };
|
|
269
|
+
}
|
|
270
|
+
return { address: undefined };
|
|
271
|
+
},
|
|
272
|
+
error: undefined,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
// If it's already a ClawnchDeployError, preserve it
|
|
277
|
+
if (err instanceof ClawnchDeployError) {
|
|
278
|
+
return {
|
|
279
|
+
txHash: undefined,
|
|
280
|
+
waitForTransaction: async () => ({ address: undefined }),
|
|
281
|
+
error: err,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
// Classify common RPC/network errors
|
|
285
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
286
|
+
const cause = err instanceof Error ? err : undefined;
|
|
287
|
+
let code = ClawnchErrorCode.DEPLOY_FAILED;
|
|
288
|
+
if (errMsg.includes('insufficient funds') || errMsg.includes('exceeds balance')) {
|
|
289
|
+
code = ClawnchErrorCode.INSUFFICIENT_FUNDS;
|
|
290
|
+
}
|
|
291
|
+
else if (errMsg.includes('timeout') || errMsg.includes('ETIMEDOUT')) {
|
|
292
|
+
code = ClawnchErrorCode.TIMEOUT;
|
|
293
|
+
}
|
|
294
|
+
else if (errMsg.includes('could not coalesce') || errMsg.includes('missing revert data') || errMsg.includes('RPC')) {
|
|
295
|
+
code = ClawnchErrorCode.RPC_ERROR;
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
txHash: undefined,
|
|
299
|
+
waitForTransaction: async () => ({ address: undefined }),
|
|
300
|
+
error: new ClawnchDeployError(code, errMsg, cause),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=deployer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployer.js","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAQL,WAAW,GACZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAwJnE,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,IAA+B;IAC7D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;QACjC,KAAK,QAAQ,CAAC,C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|
+
* ERC-8004 is a protocol for discovering and trusting AI agents across organizational boundaries.
|
|
5
|
+
* https://eips.ethereum.org/EIPS/eip-8004
|
|
6
|
+
*/
|
|
7
|
+
export type ERC8004TrustModels = 'reputation' | 'crypto-economic' | 'tee-attestation';
|
|
8
|
+
export type ERC8004ChainId = 'eip155:1' | 'eip155:11155111' | 'eip155:8453' | 'eip155:84532' | 'eip155:59144' | 'eip155:11155420' | 'eip155:80002' | 'solana:101' | 'solana:102';
|
|
9
|
+
export interface ERC8004Endpoint {
|
|
10
|
+
name: string;
|
|
11
|
+
endpoint: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ERC8004Wallet {
|
|
16
|
+
chain: ERC8004ChainId;
|
|
17
|
+
address: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ERC8004Registration {
|
|
21
|
+
agentId: number;
|
|
22
|
+
agentRegistry: ERC8004ChainId;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
blockNumber?: number;
|
|
25
|
+
transactionHash?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ERC8004Skill {
|
|
28
|
+
namespace: string;
|
|
29
|
+
skill: string;
|
|
30
|
+
domain?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ERC8004Domain {
|
|
33
|
+
category: string;
|
|
34
|
+
subcategory?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ERC8004ReputationScore {
|
|
37
|
+
overall: number;
|
|
38
|
+
totalRatings: number;
|
|
39
|
+
breakdown?: {
|
|
40
|
+
reliability?: number;
|
|
41
|
+
quality?: number;
|
|
42
|
+
responsiveness?: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface ERC8004Agent {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
image: string;
|
|
50
|
+
active: boolean;
|
|
51
|
+
endpoints: ERC8004Endpoint[];
|
|
52
|
+
wallets: ERC8004Wallet[];
|
|
53
|
+
registrations: ERC8004Registration[];
|
|
54
|
+
supportedTrust: ERC8004TrustModels[];
|
|
55
|
+
skills?: ERC8004Skill[];
|
|
56
|
+
domains?: ERC8004Domain[];
|
|
57
|
+
reputation?: ERC8004ReputationScore;
|
|
58
|
+
metadata?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface ERC8004AgentCard {
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
url: string;
|
|
64
|
+
version: string;
|
|
65
|
+
capabilities?: {
|
|
66
|
+
streaming?: boolean;
|
|
67
|
+
pushNotifications?: boolean;
|
|
68
|
+
};
|
|
69
|
+
defaultApiVersion?: string;
|
|
70
|
+
skills?: string[];
|
|
71
|
+
}
|
|
72
|
+
export interface ERC8004SearchFilters {
|
|
73
|
+
name?: string;
|
|
74
|
+
active?: boolean;
|
|
75
|
+
trustModel?: ERC8004TrustModels;
|
|
76
|
+
chainId?: ERC8004ChainId;
|
|
77
|
+
skills?: string[];
|
|
78
|
+
domains?: string[];
|
|
79
|
+
limit?: number;
|
|
80
|
+
offset?: number;
|
|
81
|
+
}
|
|
82
|
+
export interface ERC8004SearchResult {
|
|
83
|
+
agents: ERC8004Agent[];
|
|
84
|
+
total: number;
|
|
85
|
+
hasMore: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface ERC8004RegistryConfig {
|
|
88
|
+
chainId: ERC8004ChainId;
|
|
89
|
+
identityRegistryAddress: string;
|
|
90
|
+
reputationRegistryAddress?: string;
|
|
91
|
+
validationRegistryAddress?: string;
|
|
92
|
+
blockNumber?: number;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=erc8004-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc8004-types.d.ts","sourceRoot":"","sources":["../src/erc8004-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,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