@alchemy/cli 0.10.0 → 0.11.1
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 +25 -26
- package/dist/{auth-KS6VPHHU.js → auth-5XFZB2BU.js} +2 -2
- package/dist/auth-AU7LPEQL.js +16 -0
- package/dist/{chunk-CTTW4PA4.js → chunk-5BEJA752.js} +21 -27
- package/dist/{chunk-D2RUM2DD.js → chunk-CJDHJYLM.js} +4 -4
- package/dist/{chunk-PMNRIXJI.js → chunk-DXQAGBW6.js} +1 -1
- package/dist/{chunk-AMGGO36F.js → chunk-I6YQX7PF.js} +1 -1
- package/dist/{chunk-L5E7GEUU.js → chunk-ILPOKA4Y.js} +6 -6
- package/dist/{chunk-GLKB4JM7.js → chunk-LANOFNO6.js} +1 -11
- package/dist/{chunk-ANONMDDZ.js → chunk-OL5MEN62.js} +66 -87
- package/dist/{chunk-VN5JUWHO.js → chunk-QWLBZTG5.js} +7 -12
- package/dist/{chunk-3GBDYROJ.js → chunk-RPSHRYCZ.js} +1 -1
- package/dist/{chunk-HRWD4V2P.js → chunk-SRGDGXY5.js} +3 -3
- package/dist/{errors-YPNK3AVF.js → errors-6BEPCY5N.js} +5 -5
- package/dist/index.js +196 -157
- package/dist/{interactive-D34T7RI6.js → interactive-NPBITOGO.js} +7 -9
- package/dist/{onboarding-A7IOH2MX.js → onboarding-QOZOX4CZ.js} +6 -6
- package/dist/{policy-prompt-V6W7CPAO.js → policy-prompt-YU6L2VJZ.js} +5 -5
- package/dist/{resolve-REZCFZZ7.js → resolve-WXXPXPCU.js} +9 -5
- package/package.json +1 -1
- package/dist/auth-23OYLRWN.js +0 -16
package/dist/index.js
CHANGED
|
@@ -5,26 +5,27 @@ import {
|
|
|
5
5
|
errNotLoggedInForPolicyLookup,
|
|
6
6
|
errSponsorshipNeedsPolicy,
|
|
7
7
|
selectOrCreatePolicy
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CJDHJYLM.js";
|
|
9
9
|
import {
|
|
10
10
|
registerAuth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ILPOKA4Y.js";
|
|
12
12
|
import {
|
|
13
13
|
openBrowser
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-I6YQX7PF.js";
|
|
15
15
|
import {
|
|
16
16
|
SETUP_CAPABILITY_LABELS,
|
|
17
17
|
SETUP_CAPABILITY_ORDER,
|
|
18
18
|
getSetupStatus,
|
|
19
19
|
isSetupComplete,
|
|
20
20
|
shouldRunOnboarding
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-QWLBZTG5.js";
|
|
22
22
|
import {
|
|
23
23
|
isInteractiveAllowed
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-RPSHRYCZ.js";
|
|
25
25
|
import {
|
|
26
26
|
RpcApiError,
|
|
27
27
|
adminClientFromFlags,
|
|
28
|
+
apiKeyClientFromFlags,
|
|
28
29
|
clearSession,
|
|
29
30
|
clientFromFlags,
|
|
30
31
|
createPendingSession,
|
|
@@ -47,6 +48,8 @@ import {
|
|
|
47
48
|
resolveGasPolicyId,
|
|
48
49
|
resolveGasSponsored,
|
|
49
50
|
resolveNetwork,
|
|
51
|
+
resolveOptionalNetwork,
|
|
52
|
+
resolveRequiredNetwork,
|
|
50
53
|
resolveSolanaFeePolicyId,
|
|
51
54
|
resolveSolanaFeeSponsored,
|
|
52
55
|
resolveSolanaNetwork,
|
|
@@ -60,12 +63,12 @@ import {
|
|
|
60
63
|
updateSession,
|
|
61
64
|
validateNetwork,
|
|
62
65
|
walletNetworkToChain
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-OL5MEN62.js";
|
|
64
67
|
import {
|
|
65
68
|
getAvailableUpdate,
|
|
66
69
|
getUpdateStatus,
|
|
67
70
|
printUpdateNotice
|
|
68
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-SRGDGXY5.js";
|
|
69
72
|
import {
|
|
70
73
|
bold,
|
|
71
74
|
brand,
|
|
@@ -89,7 +92,7 @@ import {
|
|
|
89
92
|
weiToEth,
|
|
90
93
|
withSpinner,
|
|
91
94
|
yellow
|
|
92
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-DXQAGBW6.js";
|
|
93
96
|
import {
|
|
94
97
|
KEY_MAP,
|
|
95
98
|
configDir,
|
|
@@ -100,7 +103,7 @@ import {
|
|
|
100
103
|
save,
|
|
101
104
|
toMap,
|
|
102
105
|
validKeys
|
|
103
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-LANOFNO6.js";
|
|
104
107
|
import {
|
|
105
108
|
CLIError,
|
|
106
109
|
EXIT_CODES,
|
|
@@ -120,6 +123,7 @@ import {
|
|
|
120
123
|
errSolanaTransactionFailed,
|
|
121
124
|
errSolanaWalletKeyRequired,
|
|
122
125
|
errWalletKeyRequired,
|
|
126
|
+
errWalletRequired,
|
|
123
127
|
esc,
|
|
124
128
|
exitWithError,
|
|
125
129
|
fetchWithTimeout,
|
|
@@ -129,16 +133,18 @@ import {
|
|
|
129
133
|
isJSONMode,
|
|
130
134
|
isLocalhost,
|
|
131
135
|
isReplMode,
|
|
136
|
+
isRevealMode,
|
|
132
137
|
noColor,
|
|
133
138
|
parseBaseURLOverride,
|
|
134
139
|
printHuman,
|
|
135
140
|
printJSON,
|
|
136
141
|
quiet,
|
|
142
|
+
redactSensitiveText,
|
|
137
143
|
setFlags,
|
|
138
144
|
setNoColor,
|
|
139
145
|
timeout,
|
|
140
146
|
verbose
|
|
141
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-5BEJA752.js";
|
|
142
148
|
|
|
143
149
|
// src/index.ts
|
|
144
150
|
import { Command, Help } from "commander";
|
|
@@ -497,16 +503,6 @@ function registerConfig(program2) {
|
|
|
497
503
|
exitWithError(err);
|
|
498
504
|
}
|
|
499
505
|
});
|
|
500
|
-
setCmd.command("network <network>").description("Set the default network (e.g. eth-mainnet, polygon-mainnet)").action((network) => {
|
|
501
|
-
try {
|
|
502
|
-
const cfg = load();
|
|
503
|
-
save({ ...cfg, network });
|
|
504
|
-
printHuman(`${green("\u2713")} Set network to ${network}
|
|
505
|
-
`, { key: "network", value: network, status: "set" });
|
|
506
|
-
} catch (err) {
|
|
507
|
-
exitWithError(err);
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
506
|
setCmd.command("verbose <enabled>").description("Set default verbose output (true|false)").action((enabled) => {
|
|
511
507
|
try {
|
|
512
508
|
const normalized = enabled.trim().toLowerCase();
|
|
@@ -585,8 +581,8 @@ function registerConfig(program2) {
|
|
|
585
581
|
"Interactive policy selection requires an interactive terminal. Pass an ID: `alchemy config set evm-gas-policy-id <id>`."
|
|
586
582
|
);
|
|
587
583
|
}
|
|
588
|
-
const { selectOrCreatePolicy: selectOrCreatePolicy2 } = await import("./policy-prompt-
|
|
589
|
-
const { resolveNetwork: resolveNetwork2 } = await import("./resolve-
|
|
584
|
+
const { selectOrCreatePolicy: selectOrCreatePolicy2 } = await import("./policy-prompt-YU6L2VJZ.js");
|
|
585
|
+
const { resolveNetwork: resolveNetwork2 } = await import("./resolve-WXXPXPCU.js");
|
|
590
586
|
const network = resolveNetwork2(program2);
|
|
591
587
|
await selectOrCreatePolicy2({
|
|
592
588
|
flavor: "sponsorship",
|
|
@@ -640,8 +636,8 @@ function registerConfig(program2) {
|
|
|
640
636
|
"Interactive policy selection requires an interactive terminal. Pass an ID: `alchemy config set solana-fee-policy-id <id>`."
|
|
641
637
|
);
|
|
642
638
|
}
|
|
643
|
-
const { selectOrCreatePolicy: selectOrCreatePolicy2 } = await import("./policy-prompt-
|
|
644
|
-
const { resolveSolanaNetwork: resolveSolanaNetwork2 } = await import("./resolve-
|
|
639
|
+
const { selectOrCreatePolicy: selectOrCreatePolicy2 } = await import("./policy-prompt-YU6L2VJZ.js");
|
|
640
|
+
const { resolveSolanaNetwork: resolveSolanaNetwork2 } = await import("./resolve-WXXPXPCU.js");
|
|
645
641
|
const network = resolveSolanaNetwork2(program2);
|
|
646
642
|
await selectOrCreatePolicy2({
|
|
647
643
|
flavor: "solana",
|
|
@@ -663,13 +659,12 @@ function registerConfig(program2) {
|
|
|
663
659
|
exitWithError(err);
|
|
664
660
|
}
|
|
665
661
|
});
|
|
666
|
-
cmd.command("get <key>").description("Get a config value (api-key, app,
|
|
662
|
+
cmd.command("get <key>").description("Get a config value (api-key, app, verbose, wallet-key-file, x402)").action((key) => {
|
|
667
663
|
const cfg = load();
|
|
668
664
|
let value = get(cfg, key);
|
|
669
665
|
let isDefault = false;
|
|
670
666
|
if (value === void 0) {
|
|
671
667
|
const defaults = {
|
|
672
|
-
network: "eth-mainnet",
|
|
673
668
|
verbose: "false",
|
|
674
669
|
x402: "false",
|
|
675
670
|
evm_gas_sponsored: "false",
|
|
@@ -699,7 +694,7 @@ function registerConfig(program2) {
|
|
|
699
694
|
printJSON(toMap(cfg));
|
|
700
695
|
return;
|
|
701
696
|
}
|
|
702
|
-
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-
|
|
697
|
+
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-WXXPXPCU.js");
|
|
703
698
|
const validToken = resolveAuthToken2(cfg);
|
|
704
699
|
const authStatus = cfg.auth_token ? validToken ? `${green("\u2713")} authenticated${cfg.auth_token_expires_at ? ` ${dim(`(expires ${cfg.auth_token_expires_at})`)}` : ""}` : `${yellow("\u25C6")} expired${cfg.auth_token_expires_at ? ` ${dim(`(${cfg.auth_token_expires_at})`)}` : ""}` : dim("(not set) \u2014 run 'alchemy auth' to log in");
|
|
705
700
|
const pairs = [
|
|
@@ -713,7 +708,6 @@ function registerConfig(program2) {
|
|
|
713
708
|
"app",
|
|
714
709
|
cfg.app ? `${cfg.app.name} ${dim(`(${cfg.app.id})`)}` : dim("(not set) \u2014 set automatically via 'alchemy auth' or 'config set app'")
|
|
715
710
|
],
|
|
716
|
-
["network", cfg.network || dim("(not set, defaults to eth-mainnet)")],
|
|
717
711
|
[
|
|
718
712
|
"verbose",
|
|
719
713
|
cfg.verbose !== void 0 ? String(cfg.verbose) : dim("(not set, defaults to false)")
|
|
@@ -835,12 +829,24 @@ function registerVersion(program2) {
|
|
|
835
829
|
}
|
|
836
830
|
|
|
837
831
|
// src/commands/apps.ts
|
|
832
|
+
function redactAppUrl(value) {
|
|
833
|
+
return isRevealMode() ? value : redactSensitiveText(value);
|
|
834
|
+
}
|
|
838
835
|
function maskAppSecrets(app) {
|
|
839
|
-
|
|
836
|
+
const masked = {
|
|
840
837
|
...app,
|
|
841
838
|
...app.apiKey !== void 0 && { apiKey: maskIf(app.apiKey) },
|
|
842
839
|
...app.webhookApiKey !== void 0 && { webhookApiKey: maskIf(app.webhookApiKey) }
|
|
843
840
|
};
|
|
841
|
+
if (app.chainNetworks !== void 0) {
|
|
842
|
+
masked.chainNetworks = app.chainNetworks.map((network) => ({
|
|
843
|
+
...network,
|
|
844
|
+
...network.rpcUrl !== void 0 && { rpcUrl: redactAppUrl(network.rpcUrl) },
|
|
845
|
+
...network.wsUrl !== void 0 && { wsUrl: redactAppUrl(network.wsUrl) },
|
|
846
|
+
...network.grpcUrl !== void 0 && { grpcUrl: redactAppUrl(network.grpcUrl) }
|
|
847
|
+
}));
|
|
848
|
+
}
|
|
849
|
+
return masked;
|
|
844
850
|
}
|
|
845
851
|
function printFetchSummary(appsCount, pagesCount, opts) {
|
|
846
852
|
const suffix = opts?.suffix ? ` ${opts.suffix}` : "";
|
|
@@ -3172,6 +3178,24 @@ function resolveWebhookApiKey(opts) {
|
|
|
3172
3178
|
const cfg = load();
|
|
3173
3179
|
return opts?.webhookApiKey || opts?.notifyToken || process.env.ALCHEMY_WEBHOOK_API_KEY || process.env.ALCHEMY_NOTIFY_AUTH_TOKEN || cfg.webhook_api_key || cfg.app?.webhookApiKey;
|
|
3174
3180
|
}
|
|
3181
|
+
function isWebhookSigningKey(key) {
|
|
3182
|
+
const normalized = key.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3183
|
+
return (normalized.includes("signing") || normalized.includes("hmac")) && (normalized.includes("key") || normalized.includes("secret"));
|
|
3184
|
+
}
|
|
3185
|
+
function maskWebhookSecrets(value) {
|
|
3186
|
+
if (Array.isArray(value)) {
|
|
3187
|
+
return value.map(maskWebhookSecrets);
|
|
3188
|
+
}
|
|
3189
|
+
if (value && typeof value === "object") {
|
|
3190
|
+
return Object.fromEntries(
|
|
3191
|
+
Object.entries(value).map(([key, nested]) => [
|
|
3192
|
+
key,
|
|
3193
|
+
isWebhookSigningKey(key) && typeof nested === "string" ? maskIf(nested) : maskWebhookSecrets(nested)
|
|
3194
|
+
])
|
|
3195
|
+
);
|
|
3196
|
+
}
|
|
3197
|
+
return value;
|
|
3198
|
+
}
|
|
3175
3199
|
function registerWebhooks(program2) {
|
|
3176
3200
|
const cmd = program2.command("webhook").description("Notify API wrappers");
|
|
3177
3201
|
cmd.option("--webhook-api-key <key>", "Webhook API key").option("--notify-token <token>", "Deprecated alias for webhook API key");
|
|
@@ -3183,8 +3207,9 @@ function registerWebhooks(program2) {
|
|
|
3183
3207
|
"Webhooks fetched",
|
|
3184
3208
|
() => callNotify(token, "/team-webhooks")
|
|
3185
3209
|
);
|
|
3186
|
-
|
|
3187
|
-
|
|
3210
|
+
const output = maskWebhookSecrets(result);
|
|
3211
|
+
if (isJSONMode()) printJSON(output);
|
|
3212
|
+
else printSyntaxJSON(output);
|
|
3188
3213
|
} catch (err) {
|
|
3189
3214
|
exitWithError(err);
|
|
3190
3215
|
}
|
|
@@ -3311,7 +3336,7 @@ function registerNetwork(program2) {
|
|
|
3311
3336
|
cmd.command("list").description("List RPC network IDs for use with --network (e.g. eth-mainnet)").option("--mainnet-only", "Show only mainnet networks").option("--testnet-only", "Show only testnet networks").option("--search <term>", "Filter networks by name or ID").action(async (opts) => {
|
|
3312
3337
|
try {
|
|
3313
3338
|
let display = getRPCNetworks();
|
|
3314
|
-
const current =
|
|
3339
|
+
const current = resolveOptionalNetwork(program2);
|
|
3315
3340
|
if (opts.mainnetOnly) {
|
|
3316
3341
|
display = display.filter((n) => !n.isTestnet);
|
|
3317
3342
|
} else if (opts.testnetOnly) {
|
|
@@ -3328,15 +3353,17 @@ function registerNetwork(program2) {
|
|
|
3328
3353
|
return;
|
|
3329
3354
|
}
|
|
3330
3355
|
const rows = display.map((network) => {
|
|
3331
|
-
const isCurrent = network.id === current;
|
|
3356
|
+
const isCurrent = current !== void 0 && network.id === current;
|
|
3332
3357
|
const idCell = isCurrent ? green(network.id) : network.id;
|
|
3333
3358
|
const nameCell = isCurrent ? green(network.name) : network.name;
|
|
3334
3359
|
const testnetCell = network.isTestnet ? dim("yes") : "no";
|
|
3335
3360
|
return [idCell, nameCell, network.family, testnetCell];
|
|
3336
3361
|
});
|
|
3337
3362
|
printTable(["Network ID", "Name", "Family", "Testnet"], rows);
|
|
3338
|
-
|
|
3363
|
+
if (current) {
|
|
3364
|
+
console.log(`
|
|
3339
3365
|
Current: ${green(current)}`);
|
|
3366
|
+
}
|
|
3340
3367
|
console.log(
|
|
3341
3368
|
` ${dim("Need Admin API chain identifiers (e.g. ETH_MAINNET)? See: app chains")}`
|
|
3342
3369
|
);
|
|
@@ -3348,7 +3375,7 @@ function registerNetwork(program2) {
|
|
|
3348
3375
|
printJSON({
|
|
3349
3376
|
mode: "all",
|
|
3350
3377
|
networks: display,
|
|
3351
|
-
currentNetwork: current
|
|
3378
|
+
currentNetwork: current ?? null
|
|
3352
3379
|
});
|
|
3353
3380
|
}
|
|
3354
3381
|
} catch (err) {
|
|
@@ -3400,7 +3427,7 @@ function formatTokenAmount(rawAmount, decimals) {
|
|
|
3400
3427
|
return frac ? `${whole}.${frac}` : whole;
|
|
3401
3428
|
}
|
|
3402
3429
|
async function fetchTokenDecimals(program2, tokenAddress, opts) {
|
|
3403
|
-
const client =
|
|
3430
|
+
const client = apiKeyClientFromFlags(
|
|
3404
3431
|
program2,
|
|
3405
3432
|
opts?.network ? { forceNetwork: opts.network } : void 0
|
|
3406
3433
|
);
|
|
@@ -5044,7 +5071,7 @@ function createAlchemyWalletTransport(apiKey) {
|
|
|
5044
5071
|
}
|
|
5045
5072
|
|
|
5046
5073
|
// src/lib/smart-wallet.ts
|
|
5047
|
-
async function ensureGasPolicyResolved(program2) {
|
|
5074
|
+
async function ensureGasPolicyResolved(program2, options = {}) {
|
|
5048
5075
|
const cfg = load();
|
|
5049
5076
|
if (!resolveGasSponsored(program2, cfg)) return void 0;
|
|
5050
5077
|
const existing = resolveGasPolicyId(program2, cfg);
|
|
@@ -5055,7 +5082,7 @@ async function ensureGasPolicyResolved(program2) {
|
|
|
5055
5082
|
if (!hasAuthLoginToken(cfg)) {
|
|
5056
5083
|
throw errNotLoggedInForPolicyLookup();
|
|
5057
5084
|
}
|
|
5058
|
-
const network = resolveNetwork(program2
|
|
5085
|
+
const network = options.networkOverride ?? resolveNetwork(program2);
|
|
5059
5086
|
const policyId = await selectOrCreatePolicy({
|
|
5060
5087
|
flavor: "sponsorship",
|
|
5061
5088
|
network,
|
|
@@ -5110,7 +5137,7 @@ function buildWalletClient(program2, options = {}) {
|
|
|
5110
5137
|
const apiKey = resolveAPIKey(program2);
|
|
5111
5138
|
if (!apiKey) throw errAuthRequired();
|
|
5112
5139
|
const cfg = load();
|
|
5113
|
-
const network = resolveNetwork(program2
|
|
5140
|
+
const network = options.networkOverride ?? resolveNetwork(program2);
|
|
5114
5141
|
const chain = networkToChain(network);
|
|
5115
5142
|
const gasSponsored = resolveGasSponsored(program2, cfg);
|
|
5116
5143
|
const gasPolicyId = options.gasPolicyIdOverride ?? resolveGasPolicyId(program2, cfg);
|
|
@@ -5152,7 +5179,9 @@ function buildWalletClient(program2, options = {}) {
|
|
|
5152
5179
|
address: evmSession.evmAddress
|
|
5153
5180
|
};
|
|
5154
5181
|
}
|
|
5155
|
-
if (!localKey)
|
|
5182
|
+
if (!localKey) {
|
|
5183
|
+
throw pref === "local" ? errWalletKeyRequired() : errWalletRequired();
|
|
5184
|
+
}
|
|
5156
5185
|
const account = privateKeyToAccount2(normalizeKey(localKey));
|
|
5157
5186
|
return {
|
|
5158
5187
|
signer: account,
|
|
@@ -5245,10 +5274,10 @@ function registerStatus(program2, options = {}) {
|
|
|
5245
5274
|
"after",
|
|
5246
5275
|
`
|
|
5247
5276
|
Examples:
|
|
5248
|
-
alchemy evm status call-123
|
|
5277
|
+
alchemy evm status call-123 -n eth-mainnet EVM smart wallet operation
|
|
5249
5278
|
alchemy evm status 0xTxHash... -n eth-mainnet Raw EVM transaction
|
|
5250
5279
|
alchemy solana status 5wHu1qwD7q... -n solana-devnet Solana transaction
|
|
5251
|
-
echo "call-123" | alchemy evm status
|
|
5280
|
+
echo "call-123" | alchemy evm status -n eth-mainnet
|
|
5252
5281
|
|
|
5253
5282
|
Tip: use an EVM network for operation IDs and tx hashes, or a Solana network for signatures.`
|
|
5254
5283
|
).action(async (idArg) => {
|
|
@@ -6236,10 +6265,8 @@ var ERROR_RECOVERY = {
|
|
|
6236
6265
|
AUTH_REQUIRED: "Set ALCHEMY_API_KEY env var or run: alchemy config set app",
|
|
6237
6266
|
INVALID_API_KEY: "Check your API key and select a valid app: alchemy config set app",
|
|
6238
6267
|
NETWORK_NOT_ENABLED: "Enable the target network for your app at dashboard.alchemy.com",
|
|
6239
|
-
INVALID_ACCESS_KEY: "Check your access key: https://dashboard.alchemy.com/",
|
|
6240
|
-
ACCESS_KEY_REQUIRED: "Set ALCHEMY_ACCESS_KEY env var or run: alchemy config set access-key <key>",
|
|
6241
6268
|
APP_REQUIRED: "Select an app: alchemy config set app <app-id>",
|
|
6242
|
-
ADMIN_API_ERROR: "Check the error message for details; verify
|
|
6269
|
+
ADMIN_API_ERROR: "Check the error message for details; verify account permissions",
|
|
6243
6270
|
NETWORK_ERROR: "Check internet connection and retry",
|
|
6244
6271
|
RPC_ERROR: "Check RPC method, params, and network; verify API key has access",
|
|
6245
6272
|
INVALID_ARGS: "Check command usage via: alchemy --json help <command>",
|
|
@@ -6355,11 +6382,10 @@ function buildAgentPrompt(program2) {
|
|
|
6355
6382
|
]
|
|
6356
6383
|
},
|
|
6357
6384
|
{
|
|
6358
|
-
method: "
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
notes: "No command-line flag exists for access-key auth; use the env var or saved config."
|
|
6385
|
+
method: "Alchemy login",
|
|
6386
|
+
setup: "alchemy auth login",
|
|
6387
|
+
commandFamilies: ["app", "evm network", "gas-manager"],
|
|
6388
|
+
notes: "Admin surfaces use the browser login session stored by `alchemy auth login`."
|
|
6363
6389
|
},
|
|
6364
6390
|
{
|
|
6365
6391
|
method: "Webhook API key",
|
|
@@ -6416,15 +6442,15 @@ function buildAgentPrompt(program2) {
|
|
|
6416
6442
|
examples: [
|
|
6417
6443
|
"alchemy --json --no-interactive config status",
|
|
6418
6444
|
"alchemy --json --no-interactive update-check",
|
|
6419
|
-
"alchemy --json --no-interactive evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --api-key $ALCHEMY_API_KEY",
|
|
6420
|
-
"
|
|
6421
|
-
"alchemy --json --no-interactive evm rpc eth_blockNumber --api-key $ALCHEMY_API_KEY",
|
|
6445
|
+
"alchemy --json --no-interactive evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --api-key $ALCHEMY_API_KEY -n eth-mainnet",
|
|
6446
|
+
"alchemy --json --no-interactive app list",
|
|
6447
|
+
"alchemy --json --no-interactive evm rpc eth_blockNumber --api-key $ALCHEMY_API_KEY -n eth-mainnet",
|
|
6422
6448
|
"alchemy --json --no-interactive evm network list",
|
|
6423
6449
|
"alchemy --json --no-interactive evm send 0xRecipient 0.001 --dry-run -n eth-sepolia",
|
|
6424
6450
|
`alchemy --json --no-interactive evm contract read 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 "balanceOf(address)(uint256)" --args '["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"]' -n eth-mainnet`,
|
|
6425
6451
|
"alchemy --json --no-interactive evm swap quote --from 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE --to 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 --amount 1.0 --from-address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n eth-mainnet",
|
|
6426
|
-
"alchemy --json --no-interactive evm logs --from-block latest --limit 25",
|
|
6427
|
-
"alchemy --json --no-interactive evm block latest --summary",
|
|
6452
|
+
"alchemy --json --no-interactive evm logs --from-block latest --limit 25 -n eth-mainnet",
|
|
6453
|
+
"alchemy --json --no-interactive evm block latest --summary -n eth-mainnet",
|
|
6428
6454
|
"alchemy --json --no-interactive evm status 0xCallId -n eth-mainnet"
|
|
6429
6455
|
],
|
|
6430
6456
|
docs: "https://www.alchemy.com/docs"
|
|
@@ -6460,7 +6486,9 @@ function formatAsSystemPrompt(payload) {
|
|
|
6460
6486
|
lines.push("Auth methods:");
|
|
6461
6487
|
for (const auth of payload.auth) {
|
|
6462
6488
|
lines.push(` ${auth.method}:`);
|
|
6463
|
-
|
|
6489
|
+
if (auth.envVar) {
|
|
6490
|
+
lines.push(` env: ${auth.envVar}`);
|
|
6491
|
+
}
|
|
6464
6492
|
if (auth.flag) {
|
|
6465
6493
|
lines.push(` flag: ${auth.flag}`);
|
|
6466
6494
|
}
|
|
@@ -6744,11 +6772,11 @@ function registerApprove(program2) {
|
|
|
6744
6772
|
"after",
|
|
6745
6773
|
`
|
|
6746
6774
|
Examples:
|
|
6747
|
-
alchemy evm approve 0xRouter --token-address 0xUSDC --amount 100
|
|
6748
|
-
alchemy evm approve 0xRouter --token-address 0xUSDC --amount 100 --reset-first
|
|
6749
|
-
alchemy evm approve 0xRouter --token-address 0xUSDC --unlimited
|
|
6750
|
-
alchemy evm approve 0xRouter --token-address 0xUSDC --unlimited --yes
|
|
6751
|
-
alchemy evm approve 0xRouter --token-address 0xUSDC --revoke`
|
|
6775
|
+
alchemy evm approve 0xRouter --token-address 0xUSDC --amount 100 -n eth-mainnet
|
|
6776
|
+
alchemy evm approve 0xRouter --token-address 0xUSDC --amount 100 --reset-first -n eth-mainnet
|
|
6777
|
+
alchemy evm approve 0xRouter --token-address 0xUSDC --unlimited -n eth-mainnet
|
|
6778
|
+
alchemy evm approve 0xRouter --token-address 0xUSDC --unlimited --yes -n eth-mainnet
|
|
6779
|
+
alchemy evm approve 0xRouter --token-address 0xUSDC --revoke -n eth-mainnet`
|
|
6752
6780
|
).action(async (spenderArg, _opts, cmd) => {
|
|
6753
6781
|
try {
|
|
6754
6782
|
await performApprove(cmd, spenderArg, cmd.opts());
|
|
@@ -6770,8 +6798,8 @@ async function performApprove(program2, spenderArg, opts) {
|
|
|
6770
6798
|
signer,
|
|
6771
6799
|
...gasPolicyIdOverride && { gasPolicyIdOverride }
|
|
6772
6800
|
});
|
|
6773
|
-
const rpcClient =
|
|
6774
|
-
const tokenMeta = await fetchTokenDecimals(program2, opts.tokenAddress);
|
|
6801
|
+
const rpcClient = apiKeyClientFromFlags(program2, { forceNetwork: network });
|
|
6802
|
+
const tokenMeta = await fetchTokenDecimals(program2, opts.tokenAddress, { network });
|
|
6775
6803
|
const approval = buildApprovalRequest(opts, tokenMeta);
|
|
6776
6804
|
if (!await confirmUnlimitedApproval(program2, tokenMeta.symbol, spenderArg, opts)) {
|
|
6777
6805
|
return;
|
|
@@ -6887,9 +6915,9 @@ function registerBlock(program2) {
|
|
|
6887
6915
|
"after",
|
|
6888
6916
|
`
|
|
6889
6917
|
Examples:
|
|
6890
|
-
alchemy evm block latest
|
|
6891
|
-
alchemy evm block 17000000
|
|
6892
|
-
alchemy evm block 0x1`
|
|
6918
|
+
alchemy evm block latest -n eth-mainnet
|
|
6919
|
+
alchemy evm block 17000000 -n eth-mainnet
|
|
6920
|
+
alchemy evm block 0x1 -n eth-mainnet`
|
|
6893
6921
|
).action(async (blockId, opts) => {
|
|
6894
6922
|
try {
|
|
6895
6923
|
let blockParam;
|
|
@@ -7166,11 +7194,11 @@ function registerContract(program2) {
|
|
|
7166
7194
|
"after",
|
|
7167
7195
|
`
|
|
7168
7196
|
Examples:
|
|
7169
|
-
alchemy evm contract read 0xA0b8...USDC "balanceOf(address)(uint256)" --args '["0xHolder"]'
|
|
7170
|
-
alchemy evm contract read 0xA0b8...USDC "name()(string)"
|
|
7171
|
-
alchemy evm contract read 0xA0b8...USDC "decimals()(uint8)"
|
|
7172
|
-
alchemy evm contract read 0xContract balanceOf --abi-file ./erc20.json --args '["0xHolder"]'
|
|
7173
|
-
alchemy evm contract read 0xPool "quote((address,uint256))(uint256)" --args '[["0xToken", "1000000"]]' --block 12345678`
|
|
7197
|
+
alchemy evm contract read 0xA0b8...USDC "balanceOf(address)(uint256)" --args '["0xHolder"]' -n eth-mainnet
|
|
7198
|
+
alchemy evm contract read 0xA0b8...USDC "name()(string)" -n eth-mainnet
|
|
7199
|
+
alchemy evm contract read 0xA0b8...USDC "decimals()(uint8)" -n eth-mainnet
|
|
7200
|
+
alchemy evm contract read 0xContract balanceOf --abi-file ./erc20.json --args '["0xHolder"]' -n eth-mainnet
|
|
7201
|
+
alchemy evm contract read 0xPool "quote((address,uint256))(uint256)" --args '[["0xToken", "1000000"]]' --block 12345678 -n eth-mainnet`
|
|
7174
7202
|
).action(async (addressArg, functionArg, opts) => {
|
|
7175
7203
|
try {
|
|
7176
7204
|
await performContractRead(program2, addressArg, functionArg, opts);
|
|
@@ -7184,9 +7212,9 @@ Examples:
|
|
|
7184
7212
|
"after",
|
|
7185
7213
|
`
|
|
7186
7214
|
Examples:
|
|
7187
|
-
alchemy evm contract call 0xToken "approve(address,uint256)" --args '["0xSpender", "1000000"]'
|
|
7188
|
-
alchemy evm contract call 0xToken "transfer(address,uint256)" --args '["0xTo", "1000000"]'
|
|
7189
|
-
alchemy evm contract call 0xContract deposit --abi-file ./contract.json --value 0.1`
|
|
7215
|
+
alchemy evm contract call 0xToken "approve(address,uint256)" --args '["0xSpender", "1000000"]' -n eth-mainnet
|
|
7216
|
+
alchemy evm contract call 0xToken "transfer(address,uint256)" --args '["0xTo", "1000000"]' -n eth-mainnet
|
|
7217
|
+
alchemy evm contract call 0xContract deposit --abi-file ./contract.json --value 0.1 -n eth-mainnet`
|
|
7190
7218
|
).action(async (addressArg, functionArg, _opts, cmd2) => {
|
|
7191
7219
|
try {
|
|
7192
7220
|
const opts = cmd2.opts();
|
|
@@ -7250,7 +7278,7 @@ async function performContractCall(program2, addressArg, functionArg, opts) {
|
|
|
7250
7278
|
signer,
|
|
7251
7279
|
...gasPolicyIdOverride && { gasPolicyIdOverride }
|
|
7252
7280
|
});
|
|
7253
|
-
const rpcClient =
|
|
7281
|
+
const rpcClient = apiKeyClientFromFlags(program2, { forceNetwork: network });
|
|
7254
7282
|
const contractAddress = await resolveAddress(addressArg, rpcClient);
|
|
7255
7283
|
const data = encodeFunctionData2({ abi, functionName, args });
|
|
7256
7284
|
const value = opts.value !== void 0 ? parseEthValue(opts.value) : void 0;
|
|
@@ -7361,12 +7389,12 @@ function registerBalance(program2) {
|
|
|
7361
7389
|
"after",
|
|
7362
7390
|
`
|
|
7363
7391
|
Examples:
|
|
7364
|
-
alchemy evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
7392
|
+
alchemy evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n eth-mainnet
|
|
7365
7393
|
alchemy evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n polygon-mainnet
|
|
7366
|
-
echo 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | alchemy evm data balance
|
|
7367
|
-
alchemy evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --block 15537393
|
|
7368
|
-
alchemy evm data balance vitalik.eth
|
|
7369
|
-
cat addresses.txt | alchemy evm data balance`
|
|
7394
|
+
echo 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | alchemy evm data balance -n eth-mainnet
|
|
7395
|
+
alchemy evm data balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --block 15537393 -n eth-mainnet
|
|
7396
|
+
alchemy evm data balance vitalik.eth -n eth-mainnet
|
|
7397
|
+
cat addresses.txt | alchemy evm data balance -n eth-mainnet`
|
|
7370
7398
|
).option("--block <block>", "Block number, hex, or tag (default: latest)").action(async (addressArg, opts) => {
|
|
7371
7399
|
try {
|
|
7372
7400
|
const blockParam = resolveBlockParam2(opts?.block);
|
|
@@ -7414,10 +7442,10 @@ function registerNFTs(program2) {
|
|
|
7414
7442
|
"after",
|
|
7415
7443
|
`
|
|
7416
7444
|
Examples:
|
|
7417
|
-
alchemy evm data nfts 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
7418
|
-
alchemy evm data nfts metadata --contract 0x... --token-id 1
|
|
7419
|
-
alchemy evm data nfts contract 0x...
|
|
7420
|
-
echo 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | alchemy evm data nfts`
|
|
7445
|
+
alchemy evm data nfts 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n eth-mainnet
|
|
7446
|
+
alchemy evm data nfts metadata --contract 0x... --token-id 1 -n eth-mainnet
|
|
7447
|
+
alchemy evm data nfts contract 0x... -n eth-mainnet
|
|
7448
|
+
echo 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | alchemy evm data nfts -n eth-mainnet`
|
|
7421
7449
|
).action(async (addressArg, opts) => {
|
|
7422
7450
|
try {
|
|
7423
7451
|
const addressInput = addressArg ?? await readStdinArg("address");
|
|
@@ -7638,9 +7666,9 @@ function registerTokens(program2) {
|
|
|
7638
7666
|
"after",
|
|
7639
7667
|
`
|
|
7640
7668
|
Examples:
|
|
7641
|
-
alchemy evm data tokens balances 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
7642
|
-
alchemy evm data tokens balances 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --metadata
|
|
7643
|
-
echo 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | alchemy evm data tokens balances`
|
|
7669
|
+
alchemy evm data tokens balances 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n eth-mainnet
|
|
7670
|
+
alchemy evm data tokens balances 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --metadata -n eth-mainnet
|
|
7671
|
+
echo 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 | alchemy evm data tokens balances -n eth-mainnet`
|
|
7644
7672
|
).action(async (addressArg, opts) => {
|
|
7645
7673
|
try {
|
|
7646
7674
|
const addressInput = addressArg ?? await readStdinArg("address");
|
|
@@ -7745,7 +7773,7 @@ Examples:
|
|
|
7745
7773
|
"after",
|
|
7746
7774
|
`
|
|
7747
7775
|
Examples:
|
|
7748
|
-
alchemy evm data tokens metadata 0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eB48`
|
|
7776
|
+
alchemy evm data tokens metadata 0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eB48 -n eth-mainnet`
|
|
7749
7777
|
).action(async (contract) => {
|
|
7750
7778
|
try {
|
|
7751
7779
|
validateAddress(contract);
|
|
@@ -7816,16 +7844,16 @@ function registerTransfers(program2) {
|
|
|
7816
7844
|
`
|
|
7817
7845
|
Examples:
|
|
7818
7846
|
# Outgoing transfers from an address
|
|
7819
|
-
alchemy evm data history 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
7847
|
+
alchemy evm data history 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n eth-mainnet
|
|
7820
7848
|
|
|
7821
7849
|
# Incoming transfers to an address
|
|
7822
|
-
alchemy evm data history --to-address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
|
|
7850
|
+
alchemy evm data history --to-address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 -n eth-mainnet
|
|
7823
7851
|
|
|
7824
7852
|
# Outgoing ERC-20 transfers only
|
|
7825
|
-
alchemy evm data history --from-address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --category erc20
|
|
7853
|
+
alchemy evm data history --from-address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --category erc20 -n eth-mainnet
|
|
7826
7854
|
|
|
7827
7855
|
# Transfers within a block range
|
|
7828
|
-
alchemy evm data history 0xd8dA... --from-block 0x100000 --to-block latest`
|
|
7856
|
+
alchemy evm data history 0xd8dA... --from-block 0x100000 --to-block latest -n eth-mainnet`
|
|
7829
7857
|
).action(async (addressArg, opts) => {
|
|
7830
7858
|
try {
|
|
7831
7859
|
const client = clientFromFlags(program2);
|
|
@@ -8083,9 +8111,9 @@ function registerGas(program2) {
|
|
|
8083
8111
|
"after",
|
|
8084
8112
|
`
|
|
8085
8113
|
Examples:
|
|
8086
|
-
alchemy evm gas
|
|
8114
|
+
alchemy evm gas -n eth-mainnet
|
|
8087
8115
|
alchemy evm gas -n polygon-mainnet
|
|
8088
|
-
alchemy evm gas --json`
|
|
8116
|
+
alchemy evm gas --json -n eth-mainnet`
|
|
8089
8117
|
).action(async () => {
|
|
8090
8118
|
try {
|
|
8091
8119
|
const client = clientFromFlags(program2);
|
|
@@ -8197,10 +8225,10 @@ function registerLogs(program2) {
|
|
|
8197
8225
|
"after",
|
|
8198
8226
|
`
|
|
8199
8227
|
Examples:
|
|
8200
|
-
alchemy evm logs --from-block 18000000 --to-block 18000010
|
|
8201
|
-
alchemy evm logs --address 0xdAC17F958D2ee523a2206206994597C13D831ec7 --from-block 18000000 --to-block 18000010
|
|
8202
|
-
alchemy evm logs --address 0xdAC17F958D2ee523a2206206994597C13D831ec7 --topic 0xddf252ad...
|
|
8203
|
-
alchemy evm logs --from-block latest --json`
|
|
8228
|
+
alchemy evm logs --from-block 18000000 --to-block 18000010 -n eth-mainnet
|
|
8229
|
+
alchemy evm logs --address 0xdAC17F958D2ee523a2206206994597C13D831ec7 --from-block 18000000 --to-block 18000010 -n eth-mainnet
|
|
8230
|
+
alchemy evm logs --address 0xdAC17F958D2ee523a2206206994597C13D831ec7 --topic 0xddf252ad... -n eth-mainnet
|
|
8231
|
+
alchemy evm logs --from-block latest --json -n eth-mainnet`
|
|
8204
8232
|
).option("--address <address>", "Contract address to filter logs").option("--topic <topic...>", "Event topic(s) to filter (topic0, topic1, ...)").option("--from-block <block>", "Start block (number, hex, or tag)", "latest").option("--to-block <block>", "End block (number, hex, or tag)", "latest").option("--limit <n>", "Limit returned logs in output").action(async (opts) => {
|
|
8205
8233
|
try {
|
|
8206
8234
|
const outputLimit = parseOptionalInt(opts.limit, "--limit");
|
|
@@ -8289,10 +8317,10 @@ function registerReceipt(program2) {
|
|
|
8289
8317
|
"after",
|
|
8290
8318
|
`
|
|
8291
8319
|
Examples:
|
|
8292
|
-
alchemy evm receipt 0xabc123...
|
|
8293
|
-
echo 0xabc123... | alchemy evm receipt
|
|
8320
|
+
alchemy evm receipt 0xabc123... -n eth-mainnet
|
|
8321
|
+
echo 0xabc123... | alchemy evm receipt -n eth-mainnet
|
|
8294
8322
|
|
|
8295
|
-
Tip: use 'alchemy evm tx <hash>' for transaction details (value, block, nonce). Receipt provides execution results (status, gas used, logs).`
|
|
8323
|
+
Tip: use 'alchemy evm tx <hash> -n <net>' for transaction details (value, block, nonce). Receipt provides execution results (status, gas used, logs).`
|
|
8296
8324
|
).action(async (hashArg) => {
|
|
8297
8325
|
try {
|
|
8298
8326
|
const hash = hashArg ?? await readStdinArg("hash");
|
|
@@ -8356,22 +8384,16 @@ function registerRPC(program2) {
|
|
|
8356
8384
|
"after",
|
|
8357
8385
|
`
|
|
8358
8386
|
Examples:
|
|
8359
|
-
alchemy evm rpc eth_blockNumber
|
|
8360
|
-
alchemy evm rpc eth_getBalance "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" "latest"
|
|
8361
|
-
alchemy evm rpc eth_getBlockByNumber "0x1" true`
|
|
8387
|
+
alchemy evm rpc eth_blockNumber -n eth-mainnet
|
|
8388
|
+
alchemy evm rpc eth_getBalance "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" "latest" -n eth-mainnet
|
|
8389
|
+
alchemy evm rpc eth_getBlockByNumber "0x1" true -n eth-mainnet`
|
|
8362
8390
|
).action(async (method, params) => {
|
|
8363
8391
|
try {
|
|
8364
8392
|
if (outputRpcHelp(cmd, method, params)) {
|
|
8365
8393
|
return;
|
|
8366
8394
|
}
|
|
8367
8395
|
const client = clientFromFlags(program2);
|
|
8368
|
-
const parsed = params
|
|
8369
|
-
try {
|
|
8370
|
-
return JSON.parse(p);
|
|
8371
|
-
} catch {
|
|
8372
|
-
return p;
|
|
8373
|
-
}
|
|
8374
|
-
});
|
|
8396
|
+
const parsed = parseRPCParams(params);
|
|
8375
8397
|
debug(`rpc ${method} %o`, parsed);
|
|
8376
8398
|
const result = await withSpinner(
|
|
8377
8399
|
`Calling ${method}\u2026`,
|
|
@@ -8385,6 +8407,13 @@ Examples:
|
|
|
8385
8407
|
});
|
|
8386
8408
|
registerEvmRpcSurfaceCommands(program2, cmd);
|
|
8387
8409
|
}
|
|
8410
|
+
function parseRPCParams(params) {
|
|
8411
|
+
const parsed = parseCLIParams(params);
|
|
8412
|
+
if (parsed.length === 1 && Array.isArray(parsed[0])) {
|
|
8413
|
+
return parsed[0];
|
|
8414
|
+
}
|
|
8415
|
+
return parsed;
|
|
8416
|
+
}
|
|
8388
8417
|
function outputRpcHelp(cmd, method, params) {
|
|
8389
8418
|
if (method !== "help") {
|
|
8390
8419
|
return false;
|
|
@@ -8419,13 +8448,17 @@ function registerEvmSend(program2) {
|
|
|
8419
8448
|
sendCmd.option("--gas-sponsored", "Enable gas sponsorship (env: ALCHEMY_EVM_GAS_SPONSORED)").option("--gas-policy-id <id>", "Gas policy ID for sponsorship (env: ALCHEMY_EVM_GAS_POLICY_ID)").addHelpText(
|
|
8420
8449
|
"after",
|
|
8421
8450
|
`
|
|
8451
|
+
Omit --token to send the native token for the selected network.
|
|
8452
|
+
Network is required via -n/--network.
|
|
8453
|
+
|
|
8422
8454
|
Examples:
|
|
8423
|
-
alchemy evm send 0xAbC...123 1.5
|
|
8424
|
-
alchemy evm send vitalik.eth 0.1 -n base-mainnet
|
|
8425
|
-
alchemy evm send 0xAbC...123
|
|
8426
|
-
alchemy evm send 0xAbC...123
|
|
8427
|
-
alchemy evm send 0xAbC...123 1 --
|
|
8428
|
-
alchemy evm send 0xAbC...123 1
|
|
8455
|
+
alchemy evm send 0xAbC...123 1.5 -n eth-mainnet Send 1.5 ETH
|
|
8456
|
+
alchemy evm send vitalik.eth 0.1 -n base-mainnet Send 0.1 ETH on Base
|
|
8457
|
+
alchemy evm send 0xAbC...123 1 -n monad-testnet Send 1 MON
|
|
8458
|
+
alchemy evm send 0xAbC...123 100 --token 0xA0b8...USDC -n eth-mainnet Send 100 USDC
|
|
8459
|
+
alchemy evm send 0xAbC...123 1.5 --dry-run -n eth-mainnet Preview without signing or sending
|
|
8460
|
+
alchemy evm send 0xAbC...123 1 -n base-mainnet --gas-sponsored --gas-policy-id <id>
|
|
8461
|
+
alchemy evm send 0xAbC...123 1.5 --signer local -n eth-mainnet Force the local wallet`
|
|
8429
8462
|
).action(async (toArg, amountArg, _opts, cmd) => {
|
|
8430
8463
|
try {
|
|
8431
8464
|
const opts = cmd.opts();
|
|
@@ -8434,7 +8467,7 @@ Examples:
|
|
|
8434
8467
|
dryRun: opts.dryRun
|
|
8435
8468
|
});
|
|
8436
8469
|
} catch (err) {
|
|
8437
|
-
const { exitWithError: exitWithError2 } = await import("./errors-
|
|
8470
|
+
const { exitWithError: exitWithError2 } = await import("./errors-6BEPCY5N.js");
|
|
8438
8471
|
exitWithError2(err);
|
|
8439
8472
|
}
|
|
8440
8473
|
});
|
|
@@ -8443,17 +8476,25 @@ async function performEvmSend(program2, toArg, amountArg, tokenAddress, opts = {
|
|
|
8443
8476
|
if (tokenAddress) {
|
|
8444
8477
|
validateAddress(tokenAddress);
|
|
8445
8478
|
}
|
|
8446
|
-
const
|
|
8447
|
-
const
|
|
8479
|
+
const network = resolveRequiredNetwork(program2);
|
|
8480
|
+
const gasPolicyIdOverride = await ensureGasPolicyResolved(program2, {
|
|
8481
|
+
networkOverride: network
|
|
8482
|
+
});
|
|
8483
|
+
const { client, address: from, paymaster } = buildWalletClient(program2, {
|
|
8448
8484
|
signer: opts.signer,
|
|
8485
|
+
networkOverride: network,
|
|
8449
8486
|
...gasPolicyIdOverride && { gasPolicyIdOverride }
|
|
8450
8487
|
});
|
|
8451
|
-
const rpcClient =
|
|
8488
|
+
const rpcClient = apiKeyClientFromFlags(program2, {
|
|
8489
|
+
forceNetwork: network
|
|
8490
|
+
});
|
|
8452
8491
|
const to = await resolveAddress(toArg, rpcClient);
|
|
8453
8492
|
let decimals;
|
|
8454
8493
|
let symbol;
|
|
8455
8494
|
if (tokenAddress) {
|
|
8456
|
-
const meta = await fetchTokenDecimals(program2, tokenAddress
|
|
8495
|
+
const meta = await fetchTokenDecimals(program2, tokenAddress, {
|
|
8496
|
+
network
|
|
8497
|
+
});
|
|
8457
8498
|
decimals = meta.decimals;
|
|
8458
8499
|
symbol = meta.symbol;
|
|
8459
8500
|
} else {
|
|
@@ -8611,8 +8652,7 @@ import { parseAccount } from "viem/accounts";
|
|
|
8611
8652
|
function buildWalletQuoteClient(program2, address3) {
|
|
8612
8653
|
const apiKey = resolveAPIKey(program2);
|
|
8613
8654
|
if (!apiKey) throw errAuthRequired();
|
|
8614
|
-
const
|
|
8615
|
-
const network = resolveNetwork(program2, cfg);
|
|
8655
|
+
const network = resolveNetwork(program2);
|
|
8616
8656
|
const chain = networkToChain(network);
|
|
8617
8657
|
const client = createClient({
|
|
8618
8658
|
account: parseAccount(address3),
|
|
@@ -8715,7 +8755,7 @@ async function resolveTokenInfo(network, program2, tokenAddress) {
|
|
|
8715
8755
|
return { decimals: NATIVE_DECIMALS, symbol: nativeTokenSymbol(network) };
|
|
8716
8756
|
}
|
|
8717
8757
|
try {
|
|
8718
|
-
return await fetchTokenDecimals(program2, tokenAddress);
|
|
8758
|
+
return await fetchTokenDecimals(program2, tokenAddress, { network });
|
|
8719
8759
|
} catch (err) {
|
|
8720
8760
|
if (err instanceof CLIError && err.code === "INVALID_ARGS") {
|
|
8721
8761
|
throw err;
|
|
@@ -8781,14 +8821,14 @@ function registerSwap(program2) {
|
|
|
8781
8821
|
quoteCmd.addHelpText(
|
|
8782
8822
|
"after",
|
|
8783
8823
|
`
|
|
8784
|
-
Tip: use 'alchemy evm token <SYMBOL>' to resolve common token addresses
|
|
8824
|
+
Tip: use 'alchemy evm token <SYMBOL> -n <net>' to resolve common token addresses
|
|
8785
8825
|
(ETH, USDC, WETH, USDT, DAI, \u2026). Example:
|
|
8786
|
-
--from $(alchemy evm token ETH --address-only) \\
|
|
8826
|
+
--from $(alchemy evm token ETH --address-only -n eth-mainnet) \\
|
|
8787
8827
|
--to $(alchemy evm token USDC --address-only -n eth-mainnet)
|
|
8788
8828
|
|
|
8789
8829
|
Examples:
|
|
8790
8830
|
alchemy evm swap quote --from 0xEeee...EEeE --to 0xA0b8...USDC --amount 1.0 -n eth-mainnet
|
|
8791
|
-
alchemy evm swap quote --from 0xUSDC --to 0xDAI --amount 100 --slippage 1.0`
|
|
8831
|
+
alchemy evm swap quote --from 0xUSDC --to 0xDAI --amount 100 --slippage 1.0 -n eth-mainnet`
|
|
8792
8832
|
).action(async (opts) => {
|
|
8793
8833
|
try {
|
|
8794
8834
|
await performSwapQuote(program2, opts);
|
|
@@ -8801,14 +8841,14 @@ Examples:
|
|
|
8801
8841
|
executeCmd.option("--gas-sponsored", "Enable gas sponsorship (env: ALCHEMY_EVM_GAS_SPONSORED)").option("--gas-policy-id <id>", "Gas policy ID for sponsorship (env: ALCHEMY_EVM_GAS_POLICY_ID)").addHelpText(
|
|
8802
8842
|
"after",
|
|
8803
8843
|
`
|
|
8804
|
-
Tip: use 'alchemy evm token <SYMBOL>' to resolve common token addresses
|
|
8805
|
-
(ETH, USDC, WETH, USDT, DAI, \u2026). Run 'alchemy evm token list' to discover
|
|
8806
|
-
known symbols on
|
|
8844
|
+
Tip: use 'alchemy evm token <SYMBOL> -n <net>' to resolve common token addresses
|
|
8845
|
+
(ETH, USDC, WETH, USDT, DAI, \u2026). Run 'alchemy evm token list -n <net>' to discover
|
|
8846
|
+
known symbols on that network.
|
|
8807
8847
|
|
|
8808
8848
|
Examples:
|
|
8809
8849
|
alchemy evm swap execute --from 0xEeee...EEeE --to 0xA0b8...USDC --amount 1.0 -n eth-mainnet
|
|
8810
|
-
alchemy evm swap execute --from 0xUSDC --to 0xDAI --amount 100 --slippage 1.0
|
|
8811
|
-
alchemy evm swap execute --from 0xEeee...EEeE --to 0xUSDC --amount 0.1 --gas-sponsored --gas-policy-id <id
|
|
8850
|
+
alchemy evm swap execute --from 0xUSDC --to 0xDAI --amount 100 --slippage 1.0 -n eth-mainnet
|
|
8851
|
+
alchemy evm swap execute --from 0xEeee...EEeE --to 0xUSDC --amount 0.1 --gas-sponsored --gas-policy-id <id> -n eth-mainnet`
|
|
8812
8852
|
).action(async (_opts, cmd2) => {
|
|
8813
8853
|
try {
|
|
8814
8854
|
const opts = cmd2.opts();
|
|
@@ -8991,20 +9031,20 @@ applicable. The native gas token (ETH, POL, BNB, AVAX, \u2026) resolves to the
|
|
|
8991
9031
|
EIP-7528 native sentinel 0xEeee\u2026EEeE.
|
|
8992
9032
|
|
|
8993
9033
|
Examples:
|
|
8994
|
-
alchemy evm token ETH
|
|
9034
|
+
alchemy evm token ETH -n eth-mainnet
|
|
8995
9035
|
alchemy evm token USDC -n base-mainnet
|
|
8996
9036
|
alchemy evm token USDC.e -n arb-mainnet
|
|
8997
|
-
alchemy evm token USDC --address-only
|
|
8998
|
-
alchemy --json evm token USDC | jq -r .address
|
|
9037
|
+
alchemy evm token USDC --address-only -n base-mainnet
|
|
9038
|
+
alchemy --json evm token USDC -n base-mainnet | jq -r .address
|
|
8999
9039
|
|
|
9000
|
-
alchemy evm token list
|
|
9040
|
+
alchemy evm token list -n eth-mainnet
|
|
9001
9041
|
alchemy evm token list --all # list tokens across all networks`
|
|
9002
9042
|
).action(async (symbol, opts) => {
|
|
9003
9043
|
try {
|
|
9004
9044
|
if (!symbol) {
|
|
9005
9045
|
if (opts.addressOnly) {
|
|
9006
9046
|
throw errInvalidArgs(
|
|
9007
|
-
"--address-only requires a symbol. Example: alchemy evm token USDC --address-only"
|
|
9047
|
+
"--address-only requires a symbol. Example: alchemy evm token USDC --address-only -n base-mainnet"
|
|
9008
9048
|
);
|
|
9009
9049
|
}
|
|
9010
9050
|
await runList(program2, {});
|
|
@@ -9079,7 +9119,7 @@ async function runList(program2, opts) {
|
|
|
9079
9119
|
}
|
|
9080
9120
|
console.log(
|
|
9081
9121
|
`
|
|
9082
|
-
${dim("Tip: pass -n/--network <net> to scope a lookup. Use 'alchemy evm token <SYMBOL>' to fetch a single address.")}`
|
|
9122
|
+
${dim("Tip: pass -n/--network <net> to scope a lookup. Use 'alchemy evm token <SYMBOL> -n <net>' to fetch a single address.")}`
|
|
9083
9123
|
);
|
|
9084
9124
|
return;
|
|
9085
9125
|
}
|
|
@@ -9100,7 +9140,7 @@ async function runList(program2, opts) {
|
|
|
9100
9140
|
printTokenTable(tokens);
|
|
9101
9141
|
console.log(
|
|
9102
9142
|
`
|
|
9103
|
-
${dim("Tip: 'alchemy evm token <SYMBOL>' resolves one symbol. Add --all to see every network.")}`
|
|
9143
|
+
${dim("Tip: 'alchemy evm token <SYMBOL> -n <net>' resolves one symbol. Add --all to see every network.")}`
|
|
9104
9144
|
);
|
|
9105
9145
|
}
|
|
9106
9146
|
function printTokenTable(tokens) {
|
|
@@ -9146,10 +9186,10 @@ function registerTx(program2) {
|
|
|
9146
9186
|
"after",
|
|
9147
9187
|
`
|
|
9148
9188
|
Examples:
|
|
9149
|
-
alchemy evm tx 0xabc123...
|
|
9150
|
-
echo 0xabc123... | alchemy evm tx
|
|
9189
|
+
alchemy evm tx 0xabc123... -n eth-mainnet
|
|
9190
|
+
echo 0xabc123... | alchemy evm tx -n eth-mainnet
|
|
9151
9191
|
|
|
9152
|
-
Tip: use 'alchemy evm receipt <hash>' to get the transaction receipt (status, gas used, logs).`
|
|
9192
|
+
Tip: use 'alchemy evm receipt <hash> -n <net>' to get the transaction receipt (status, gas used, logs).`
|
|
9153
9193
|
).action(async (hashArg) => {
|
|
9154
9194
|
try {
|
|
9155
9195
|
const hash = hashArg ?? await readStdinArg("hash");
|
|
@@ -9497,7 +9537,7 @@ function registerBridge(program2) {
|
|
|
9497
9537
|
Source network comes from the global -n/--network flag. Use --to-network for the destination chain.
|
|
9498
9538
|
For same-chain token exchanges, use 'alchemy evm swap'.
|
|
9499
9539
|
|
|
9500
|
-
Tip: use 'alchemy evm token <SYMBOL>' to resolve common token addresses
|
|
9540
|
+
Tip: use 'alchemy evm token <SYMBOL> -n <net>' to resolve common token addresses
|
|
9501
9541
|
(ETH, USDC, WETH, USDT, DAI, \u2026) per chain.
|
|
9502
9542
|
|
|
9503
9543
|
Examples:
|
|
@@ -9518,7 +9558,7 @@ Examples:
|
|
|
9518
9558
|
Source network comes from the global -n/--network flag. Use --to-network for the destination chain.
|
|
9519
9559
|
For same-chain token exchanges, use 'alchemy evm swap'.
|
|
9520
9560
|
|
|
9521
|
-
Tip: use 'alchemy evm token <SYMBOL>' to resolve common token addresses
|
|
9561
|
+
Tip: use 'alchemy evm token <SYMBOL> -n <net>' to resolve common token addresses
|
|
9522
9562
|
(ETH, USDC, WETH, USDT, DAI, \u2026) per chain.
|
|
9523
9563
|
|
|
9524
9564
|
Examples:
|
|
@@ -10203,11 +10243,10 @@ function doctorSetupStatus(setup) {
|
|
|
10203
10243
|
...setup,
|
|
10204
10244
|
complete: x402OnlySetup ? false : setup.complete,
|
|
10205
10245
|
satisfiedBy: x402OnlySetup ? null : setup.satisfiedBy,
|
|
10206
|
-
missing: x402OnlySetup ? ["Provide one auth path: alchemy auth OR api-key
|
|
10246
|
+
missing: x402OnlySetup ? ["Provide one auth path: alchemy auth OR api-key"] : removeX402SetupMissing(setup.missing),
|
|
10207
10247
|
nextCommands: x402OnlySetup ? [
|
|
10208
10248
|
"alchemy auth",
|
|
10209
|
-
"alchemy config set app"
|
|
10210
|
-
"alchemy config set access-key <key> && alchemy config set app <app-id>"
|
|
10249
|
+
"alchemy config set app"
|
|
10211
10250
|
] : removeX402NextCommands(setup.nextCommands),
|
|
10212
10251
|
capabilities: sanitizedCapabilities
|
|
10213
10252
|
};
|
|
@@ -10351,9 +10390,9 @@ async function flushProcessOutput() {
|
|
|
10351
10390
|
}
|
|
10352
10391
|
program.name("alchemy").description(
|
|
10353
10392
|
"The Alchemy CLI lets you query blockchain data, call JSON-RPC methods, and manage your Alchemy configuration."
|
|
10354
|
-
).version("0.
|
|
10393
|
+
).version("0.11.1", "-v, --version", "display CLI version").option("--api-key <key>", "Alchemy API key (env: ALCHEMY_API_KEY)").option(
|
|
10355
10394
|
"-n, --network <network>",
|
|
10356
|
-
"Target network
|
|
10395
|
+
"Target network for networked commands"
|
|
10357
10396
|
).option("--x402", "Use x402 wallet-based gateway auth").option(
|
|
10358
10397
|
"--wallet-key-file <path>",
|
|
10359
10398
|
"Path to wallet private key file for x402"
|
|
@@ -10489,9 +10528,9 @@ ${styledLine}`;
|
|
|
10489
10528
|
`${hBrand("\u25C6")} ${hBold("Quick Start")}`,
|
|
10490
10529
|
` ${hDim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}`,
|
|
10491
10530
|
` ${hBrand("alchemy")} ${hDim("Interactive mode with guided setup")}`,
|
|
10492
|
-
` ${hBrand("alchemy evm data balance")} ${hDim("<address>")}
|
|
10493
|
-
` ${hBrand("alchemy evm block latest")}
|
|
10494
|
-
` ${hBrand("alchemy evm rpc eth_chainId")}
|
|
10531
|
+
` ${hBrand("alchemy evm data balance")} ${hDim("<address> -n eth-mainnet")} ${hDim("Get native token balance")}`,
|
|
10532
|
+
` ${hBrand("alchemy evm block latest")} ${hDim("-n eth-mainnet")} ${hDim("Latest block summary")}`,
|
|
10533
|
+
` ${hBrand("alchemy evm rpc eth_chainId")} ${hDim("-n eth-mainnet")} ${hDim("Raw JSON-RPC call")}`,
|
|
10495
10534
|
` ${hBrand("alchemy config list")} ${hDim("View current configuration")}`,
|
|
10496
10535
|
"",
|
|
10497
10536
|
`${hBrand("\u25C6")} ${hBold("Exit Codes")}`,
|
|
@@ -10538,11 +10577,11 @@ ${styledLine}`;
|
|
|
10538
10577
|
"wallet"
|
|
10539
10578
|
];
|
|
10540
10579
|
if (!skipAppPrompt.includes(cmdName) && isInteractiveAllowed(program) && !opts.apiKey && !process.env.ALCHEMY_API_KEY) {
|
|
10541
|
-
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-
|
|
10580
|
+
const { resolveAuthToken: resolveAuthToken2 } = await import("./resolve-WXXPXPCU.js");
|
|
10542
10581
|
const authToken = resolveAuthToken2(cfg);
|
|
10543
10582
|
const hasApiKey = Boolean(cfg.api_key?.trim() || cfg.app?.apiKey);
|
|
10544
10583
|
if (authToken && !hasApiKey) {
|
|
10545
|
-
const { selectAppAfterAuth } = await import("./auth-
|
|
10584
|
+
const { selectAppAfterAuth } = await import("./auth-AU7LPEQL.js");
|
|
10546
10585
|
console.log("");
|
|
10547
10586
|
console.log(` No app selected. Please select an app to continue.`);
|
|
10548
10587
|
await selectAppAfterAuth(authToken);
|
|
@@ -10577,7 +10616,7 @@ ${styledLine}`;
|
|
|
10577
10616
|
if (isInteractiveAllowed(program)) {
|
|
10578
10617
|
let latestForInteractiveStartup = null;
|
|
10579
10618
|
if (shouldRunOnboarding(program, cfg)) {
|
|
10580
|
-
const { runOnboarding } = await import("./onboarding-
|
|
10619
|
+
const { runOnboarding } = await import("./onboarding-QOZOX4CZ.js");
|
|
10581
10620
|
const latest = getAvailableUpdateOnce();
|
|
10582
10621
|
const completed = await runOnboarding(program, latest);
|
|
10583
10622
|
updateShownDuringInteractiveStartup = Boolean(latest);
|
|
@@ -10591,7 +10630,7 @@ ${styledLine}`;
|
|
|
10591
10630
|
latestForInteractiveStartup
|
|
10592
10631
|
);
|
|
10593
10632
|
}
|
|
10594
|
-
const { startREPL } = await import("./interactive-
|
|
10633
|
+
const { startREPL } = await import("./interactive-NPBITOGO.js");
|
|
10595
10634
|
program.exitOverride();
|
|
10596
10635
|
program.configureOutput({
|
|
10597
10636
|
writeErr: () => {
|