web3-tools-mcp 1.2.3 → 1.3.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 +18 -5
- package/dist/client.d.ts +483 -411
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +107 -14
- package/dist/client.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tools/advanced.d.ts +12 -12
- package/dist/tools/balance.d.ts +6 -6
- package/dist/tools/contract-info.d.ts +12 -12
- package/dist/tools/contract.d.ts +10 -10
- package/dist/tools/ens.d.ts +20 -20
- package/dist/tools/gas.d.ts +99 -0
- package/dist/tools/gas.d.ts.map +1 -0
- package/dist/tools/gas.js +229 -0
- package/dist/tools/gas.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/logs.d.ts +4 -4
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +128 -14
- package/src/index.ts +1 -1
- package/src/tools/gas.ts +267 -0
- package/src/tools/index.ts +3 -1
- package/src/types.ts +14 -1
package/dist/tools/ens.d.ts
CHANGED
|
@@ -4,20 +4,20 @@ declare const _default: {
|
|
|
4
4
|
title: string;
|
|
5
5
|
description: string;
|
|
6
6
|
schema: z.ZodObject<{
|
|
7
|
-
chain: z.ZodDefault<z.ZodEnum<["mainnet", "base", "
|
|
7
|
+
chain: z.ZodDefault<z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>>;
|
|
8
8
|
name: z.ZodString;
|
|
9
9
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
chain: "mainnet" | "base" | "
|
|
11
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
12
12
|
name: string;
|
|
13
13
|
universalResolver?: boolean | undefined;
|
|
14
14
|
}, {
|
|
15
15
|
name: string;
|
|
16
|
-
chain?: "mainnet" | "base" | "
|
|
16
|
+
chain?: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
17
17
|
universalResolver?: boolean | undefined;
|
|
18
18
|
}>;
|
|
19
19
|
handler: (args: {
|
|
20
|
-
chain: "mainnet" | "base" | "
|
|
20
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
21
21
|
name: string;
|
|
22
22
|
universalResolver?: boolean | undefined;
|
|
23
23
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -26,20 +26,20 @@ declare const _default: {
|
|
|
26
26
|
title: string;
|
|
27
27
|
description: string;
|
|
28
28
|
schema: z.ZodObject<{
|
|
29
|
-
chain: z.ZodDefault<z.ZodEnum<["mainnet", "base", "
|
|
29
|
+
chain: z.ZodDefault<z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>>;
|
|
30
30
|
address: z.ZodString;
|
|
31
31
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
32
32
|
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
chain: "mainnet" | "base" | "
|
|
33
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
34
34
|
address: string;
|
|
35
35
|
universalResolver?: boolean | undefined;
|
|
36
36
|
}, {
|
|
37
37
|
address: string;
|
|
38
|
-
chain?: "mainnet" | "base" | "
|
|
38
|
+
chain?: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
39
39
|
universalResolver?: boolean | undefined;
|
|
40
40
|
}>;
|
|
41
41
|
handler: (args: {
|
|
42
|
-
chain: "mainnet" | "base" | "
|
|
42
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
43
43
|
address: string;
|
|
44
44
|
universalResolver?: boolean | undefined;
|
|
45
45
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -48,23 +48,23 @@ declare const _default: {
|
|
|
48
48
|
title: string;
|
|
49
49
|
description: string;
|
|
50
50
|
schema: z.ZodObject<{
|
|
51
|
-
chain: z.ZodDefault<z.ZodEnum<["mainnet", "base", "
|
|
51
|
+
chain: z.ZodDefault<z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>>;
|
|
52
52
|
name: z.ZodString;
|
|
53
53
|
key: z.ZodString;
|
|
54
54
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
chain: "mainnet" | "base" | "
|
|
56
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
57
57
|
key: string;
|
|
58
58
|
name: string;
|
|
59
59
|
universalResolver?: boolean | undefined;
|
|
60
60
|
}, {
|
|
61
61
|
key: string;
|
|
62
62
|
name: string;
|
|
63
|
-
chain?: "mainnet" | "base" | "
|
|
63
|
+
chain?: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
64
64
|
universalResolver?: boolean | undefined;
|
|
65
65
|
}>;
|
|
66
66
|
handler: (args: {
|
|
67
|
-
chain: "mainnet" | "base" | "
|
|
67
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
68
68
|
key: string;
|
|
69
69
|
name: string;
|
|
70
70
|
universalResolver?: boolean | undefined;
|
|
@@ -74,20 +74,20 @@ declare const _default: {
|
|
|
74
74
|
title: string;
|
|
75
75
|
description: string;
|
|
76
76
|
schema: z.ZodObject<{
|
|
77
|
-
chain: z.ZodDefault<z.ZodEnum<["mainnet", "base", "
|
|
77
|
+
chain: z.ZodDefault<z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>>;
|
|
78
78
|
name: z.ZodString;
|
|
79
79
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
80
80
|
}, "strip", z.ZodTypeAny, {
|
|
81
|
-
chain: "mainnet" | "base" | "
|
|
81
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
82
82
|
name: string;
|
|
83
83
|
universalResolver?: boolean | undefined;
|
|
84
84
|
}, {
|
|
85
85
|
name: string;
|
|
86
|
-
chain?: "mainnet" | "base" | "
|
|
86
|
+
chain?: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
87
87
|
universalResolver?: boolean | undefined;
|
|
88
88
|
}>;
|
|
89
89
|
handler: (args: {
|
|
90
|
-
chain: "mainnet" | "base" | "
|
|
90
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
91
91
|
name: string;
|
|
92
92
|
universalResolver?: boolean | undefined;
|
|
93
93
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -96,20 +96,20 @@ declare const _default: {
|
|
|
96
96
|
title: string;
|
|
97
97
|
description: string;
|
|
98
98
|
schema: z.ZodObject<{
|
|
99
|
-
chain: z.ZodDefault<z.ZodEnum<["mainnet", "base", "
|
|
99
|
+
chain: z.ZodDefault<z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>>;
|
|
100
100
|
names: z.ZodArray<z.ZodString, "many">;
|
|
101
101
|
universalResolver: z.ZodOptional<z.ZodBoolean>;
|
|
102
102
|
}, "strip", z.ZodTypeAny, {
|
|
103
|
-
chain: "mainnet" | "base" | "
|
|
103
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
104
104
|
names: string[];
|
|
105
105
|
universalResolver?: boolean | undefined;
|
|
106
106
|
}, {
|
|
107
107
|
names: string[];
|
|
108
|
-
chain?: "mainnet" | "base" | "
|
|
108
|
+
chain?: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost" | undefined;
|
|
109
109
|
universalResolver?: boolean | undefined;
|
|
110
110
|
}>;
|
|
111
111
|
handler: (args: {
|
|
112
|
-
chain: "mainnet" | "base" | "
|
|
112
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
113
113
|
names: string[];
|
|
114
114
|
universalResolver?: boolean | undefined;
|
|
115
115
|
}) => Promise<import("../types.js").ToolResult>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
simulate_contract: {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: z.ZodObject<{
|
|
7
|
+
chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
|
|
8
|
+
contractAddress: z.ZodString;
|
|
9
|
+
functionAbi: z.ZodString;
|
|
10
|
+
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">>;
|
|
11
|
+
from: z.ZodOptional<z.ZodString>;
|
|
12
|
+
value: z.ZodOptional<z.ZodString>;
|
|
13
|
+
blockNumber: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
16
|
+
contractAddress: string;
|
|
17
|
+
functionAbi: string;
|
|
18
|
+
blockNumber?: string | undefined;
|
|
19
|
+
from?: string | undefined;
|
|
20
|
+
value?: string | undefined;
|
|
21
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
24
|
+
contractAddress: string;
|
|
25
|
+
functionAbi: string;
|
|
26
|
+
blockNumber?: string | undefined;
|
|
27
|
+
from?: string | undefined;
|
|
28
|
+
value?: string | undefined;
|
|
29
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
handler: (args: {
|
|
32
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
33
|
+
contractAddress: string;
|
|
34
|
+
functionAbi: string;
|
|
35
|
+
blockNumber?: string | undefined;
|
|
36
|
+
from?: string | undefined;
|
|
37
|
+
value?: string | undefined;
|
|
38
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
39
|
+
}) => Promise<import("../types.js").ToolResult>;
|
|
40
|
+
};
|
|
41
|
+
estimate_gas: {
|
|
42
|
+
title: string;
|
|
43
|
+
description: string;
|
|
44
|
+
schema: z.ZodObject<{
|
|
45
|
+
chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
|
|
46
|
+
to: z.ZodOptional<z.ZodString>;
|
|
47
|
+
from: z.ZodOptional<z.ZodString>;
|
|
48
|
+
value: z.ZodOptional<z.ZodString>;
|
|
49
|
+
data: z.ZodOptional<z.ZodString>;
|
|
50
|
+
functionAbi: z.ZodOptional<z.ZodString>;
|
|
51
|
+
args: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
54
|
+
from?: string | undefined;
|
|
55
|
+
to?: string | undefined;
|
|
56
|
+
value?: string | undefined;
|
|
57
|
+
data?: string | undefined;
|
|
58
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
59
|
+
functionAbi?: string | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
62
|
+
from?: string | undefined;
|
|
63
|
+
to?: string | undefined;
|
|
64
|
+
value?: string | undefined;
|
|
65
|
+
data?: string | undefined;
|
|
66
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
67
|
+
functionAbi?: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
handler: (args: {
|
|
70
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
71
|
+
from?: string | undefined;
|
|
72
|
+
to?: string | undefined;
|
|
73
|
+
value?: string | undefined;
|
|
74
|
+
data?: string | undefined;
|
|
75
|
+
args?: (string | number | boolean | null)[] | undefined;
|
|
76
|
+
functionAbi?: string | undefined;
|
|
77
|
+
}) => Promise<import("../types.js").ToolResult>;
|
|
78
|
+
};
|
|
79
|
+
get_gas_price: {
|
|
80
|
+
title: string;
|
|
81
|
+
description: string;
|
|
82
|
+
schema: z.ZodObject<{
|
|
83
|
+
chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
|
|
84
|
+
formatted: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
87
|
+
formatted: boolean;
|
|
88
|
+
}, {
|
|
89
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
90
|
+
formatted?: boolean | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
handler: (args: {
|
|
93
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
94
|
+
formatted: boolean;
|
|
95
|
+
}) => Promise<import("../types.js").ToolResult>;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export default _default;
|
|
99
|
+
//# sourceMappingURL=gas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../src/tools/gas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKxB,wBAoQE"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { isAddress, parseAbiItem, encodeFunctionData, decodeFunctionResult } from "viem";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { getClientManager, SUPPORTED_CHAINS } from "../client.js";
|
|
4
|
+
import { convertArgumentsToTypes, createTool, formatResponse } from "../utils.js";
|
|
5
|
+
export default {
|
|
6
|
+
simulate_contract: createTool("Simulate Contract Call", "Simulate a contract call (including state-changing functions) without broadcasting. Returns simulation result and estimated gas.", z.object({
|
|
7
|
+
chain: z
|
|
8
|
+
.enum(SUPPORTED_CHAINS)
|
|
9
|
+
.describe("Blockchain network to simulate on"),
|
|
10
|
+
contractAddress: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Contract address to call"),
|
|
13
|
+
functionAbi: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('Function ABI signature (e.g., "function transfer(address to, uint256 amount)"). Can be any function type.'),
|
|
16
|
+
args: z
|
|
17
|
+
.array(z.union([z.string(), z.number(), z.boolean(), z.null()]))
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Function arguments in order matching the ABI signature"),
|
|
20
|
+
from: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Sender address (defaults to zero address)"),
|
|
24
|
+
value: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("ETH value to send with the transaction (in wei as string)"),
|
|
28
|
+
blockNumber: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Block number for simulation (defaults to latest)"),
|
|
32
|
+
}), async (args) => {
|
|
33
|
+
if (!isAddress(args.contractAddress)) {
|
|
34
|
+
throw new Error(`Invalid contract address: ${args.contractAddress}`);
|
|
35
|
+
}
|
|
36
|
+
if (args.from && !isAddress(args.from)) {
|
|
37
|
+
throw new Error(`Invalid from address: ${args.from}`);
|
|
38
|
+
}
|
|
39
|
+
const clientManager = getClientManager();
|
|
40
|
+
const client = clientManager.getClient(args.chain);
|
|
41
|
+
try {
|
|
42
|
+
const abiItem = parseAbiItem(args.functionAbi);
|
|
43
|
+
const convertedArgs = convertArgumentsToTypes(args.args || [], abiItem.inputs);
|
|
44
|
+
const blockTag = args.blockNumber ? BigInt(args.blockNumber) : undefined;
|
|
45
|
+
// Simulate the call
|
|
46
|
+
const result = await client.call({
|
|
47
|
+
to: args.contractAddress,
|
|
48
|
+
data: encodeFunctionData({
|
|
49
|
+
abi: [abiItem],
|
|
50
|
+
functionName: abiItem.name,
|
|
51
|
+
args: convertedArgs,
|
|
52
|
+
}),
|
|
53
|
+
account: args.from ? args.from : undefined,
|
|
54
|
+
value: args.value ? BigInt(args.value) : undefined,
|
|
55
|
+
blockNumber: blockTag,
|
|
56
|
+
});
|
|
57
|
+
// Also estimate gas
|
|
58
|
+
const gasEstimate = await client.estimateGas({
|
|
59
|
+
to: args.contractAddress,
|
|
60
|
+
data: encodeFunctionData({
|
|
61
|
+
abi: [abiItem],
|
|
62
|
+
functionName: abiItem.name,
|
|
63
|
+
args: convertedArgs,
|
|
64
|
+
}),
|
|
65
|
+
account: args.from ? args.from : undefined,
|
|
66
|
+
value: args.value ? BigInt(args.value) : undefined,
|
|
67
|
+
blockNumber: blockTag,
|
|
68
|
+
});
|
|
69
|
+
// Decode the result if the function has outputs
|
|
70
|
+
let decodedResult = result.data;
|
|
71
|
+
if (abiItem.outputs && abiItem.outputs.length > 0 && result.data) {
|
|
72
|
+
decodedResult = decodeFunctionResult({
|
|
73
|
+
abi: [abiItem],
|
|
74
|
+
functionName: abiItem.name,
|
|
75
|
+
data: result.data,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return formatResponse({
|
|
79
|
+
success: true,
|
|
80
|
+
chain: args.chain,
|
|
81
|
+
contractAddress: args.contractAddress,
|
|
82
|
+
functionName: abiItem.name,
|
|
83
|
+
result: decodedResult,
|
|
84
|
+
rawData: result.data,
|
|
85
|
+
gasEstimate: gasEstimate.toString(),
|
|
86
|
+
blockNumber: args.blockNumber || "latest",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Check if it's a revert error
|
|
91
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
92
|
+
return formatResponse({
|
|
93
|
+
success: false,
|
|
94
|
+
chain: args.chain,
|
|
95
|
+
contractAddress: args.contractAddress,
|
|
96
|
+
error: errorMessage,
|
|
97
|
+
reverted: errorMessage.includes("revert") || errorMessage.includes("execution reverted"),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
estimate_gas: createTool("Estimate Gas", "Estimate gas required for a transaction. Supports contract calls, transfers, and deployments.", z.object({
|
|
102
|
+
chain: z
|
|
103
|
+
.enum(SUPPORTED_CHAINS)
|
|
104
|
+
.describe("Blockchain network"),
|
|
105
|
+
to: z
|
|
106
|
+
.string()
|
|
107
|
+
.optional()
|
|
108
|
+
.describe("Recipient address (omit for contract deployment)"),
|
|
109
|
+
from: z
|
|
110
|
+
.string()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe("Sender address (optional)"),
|
|
113
|
+
value: z
|
|
114
|
+
.string()
|
|
115
|
+
.optional()
|
|
116
|
+
.describe("ETH value to send (in wei as string)"),
|
|
117
|
+
data: z
|
|
118
|
+
.string()
|
|
119
|
+
.optional()
|
|
120
|
+
.describe("Transaction data (hex string for contract calls or deployment bytecode)"),
|
|
121
|
+
functionAbi: z
|
|
122
|
+
.string()
|
|
123
|
+
.optional()
|
|
124
|
+
.describe("Optional: Function ABI signature to encode call data automatically"),
|
|
125
|
+
args: z
|
|
126
|
+
.array(z.union([z.string(), z.number(), z.boolean(), z.null()]))
|
|
127
|
+
.optional()
|
|
128
|
+
.describe("Optional: Function arguments (only used with functionAbi)"),
|
|
129
|
+
}), async (args) => {
|
|
130
|
+
if (args.to && !isAddress(args.to)) {
|
|
131
|
+
throw new Error(`Invalid to address: ${args.to}`);
|
|
132
|
+
}
|
|
133
|
+
if (args.from && !isAddress(args.from)) {
|
|
134
|
+
throw new Error(`Invalid from address: ${args.from}`);
|
|
135
|
+
}
|
|
136
|
+
const clientManager = getClientManager();
|
|
137
|
+
const client = clientManager.getClient(args.chain);
|
|
138
|
+
try {
|
|
139
|
+
let callData = args.data;
|
|
140
|
+
// If functionAbi is provided, encode the call data
|
|
141
|
+
if (args.functionAbi) {
|
|
142
|
+
const abiItem = parseAbiItem(args.functionAbi);
|
|
143
|
+
const convertedArgs = convertArgumentsToTypes(args.args || [], abiItem.inputs);
|
|
144
|
+
callData = encodeFunctionData({
|
|
145
|
+
abi: [abiItem],
|
|
146
|
+
functionName: abiItem.name,
|
|
147
|
+
args: convertedArgs,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const gasEstimate = await client.estimateGas({
|
|
151
|
+
to: args.to ? args.to : undefined,
|
|
152
|
+
account: args.from ? args.from : undefined,
|
|
153
|
+
value: args.value ? BigInt(args.value) : undefined,
|
|
154
|
+
data: callData,
|
|
155
|
+
});
|
|
156
|
+
return formatResponse({
|
|
157
|
+
success: true,
|
|
158
|
+
chain: args.chain,
|
|
159
|
+
gasEstimate: gasEstimate.toString(),
|
|
160
|
+
to: args.to,
|
|
161
|
+
from: args.from,
|
|
162
|
+
value: args.value,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
throw new Error(`Gas estimation failed: ${error}`);
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
get_gas_price: createTool("Get Gas Price", "Get current gas prices for a chain. Returns both legacy gasPrice and EIP-1559 fees (maxFeePerGas, maxPriorityFeePerGas).", z.object({
|
|
170
|
+
chain: z
|
|
171
|
+
.enum(SUPPORTED_CHAINS)
|
|
172
|
+
.describe("Blockchain network"),
|
|
173
|
+
formatted: z
|
|
174
|
+
.boolean()
|
|
175
|
+
.optional()
|
|
176
|
+
.default(true)
|
|
177
|
+
.describe("Return prices in Gwei (default: true). If false, returns wei."),
|
|
178
|
+
}), async (args) => {
|
|
179
|
+
const clientManager = getClientManager();
|
|
180
|
+
const client = clientManager.getClient(args.chain);
|
|
181
|
+
try {
|
|
182
|
+
// Get both legacy and EIP-1559 gas prices
|
|
183
|
+
const [gasPrice, feeData] = await Promise.all([
|
|
184
|
+
client.getGasPrice(),
|
|
185
|
+
client.estimateFeesPerGas().catch(() => null), // Some chains don't support EIP-1559
|
|
186
|
+
]);
|
|
187
|
+
const formatPrice = (wei) => {
|
|
188
|
+
if (args.formatted) {
|
|
189
|
+
// Convert to Gwei (1 Gwei = 1e9 wei)
|
|
190
|
+
const gwei = Number(wei) / 1e9;
|
|
191
|
+
return `${gwei.toFixed(2)} Gwei`;
|
|
192
|
+
}
|
|
193
|
+
return wei.toString();
|
|
194
|
+
};
|
|
195
|
+
const response = {
|
|
196
|
+
chain: args.chain,
|
|
197
|
+
timestamp: new Date().toISOString(),
|
|
198
|
+
legacy: {
|
|
199
|
+
gasPrice: args.formatted ? formatPrice(gasPrice) : gasPrice.toString(),
|
|
200
|
+
gasPriceWei: gasPrice.toString(),
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
// Add EIP-1559 data if available
|
|
204
|
+
if (feeData) {
|
|
205
|
+
response.eip1559 = {
|
|
206
|
+
maxFeePerGas: args.formatted
|
|
207
|
+
? formatPrice(feeData.maxFeePerGas)
|
|
208
|
+
: feeData.maxFeePerGas.toString(),
|
|
209
|
+
maxPriorityFeePerGas: args.formatted
|
|
210
|
+
? formatPrice(feeData.maxPriorityFeePerGas)
|
|
211
|
+
: feeData.maxPriorityFeePerGas.toString(),
|
|
212
|
+
maxFeePerGasWei: feeData.maxFeePerGas.toString(),
|
|
213
|
+
maxPriorityFeePerGasWei: feeData.maxPriorityFeePerGas.toString(),
|
|
214
|
+
};
|
|
215
|
+
// Calculate estimated total cost for a standard 21000 gas transaction
|
|
216
|
+
const standardGasLimit = 21000n;
|
|
217
|
+
const estimatedCost = feeData.maxFeePerGas * standardGasLimit;
|
|
218
|
+
response.eip1559.estimatedCostFor21kGas = args.formatted
|
|
219
|
+
? `${(Number(estimatedCost) / 1e18).toFixed(6)} ETH`
|
|
220
|
+
: estimatedCost.toString();
|
|
221
|
+
}
|
|
222
|
+
return formatResponse(response);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
throw new Error(`Failed to get gas price: ${error}`);
|
|
226
|
+
}
|
|
227
|
+
}),
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=gas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/tools/gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AACzH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElF,eAAe;IACb,iBAAiB,EAAE,UAAU,CAC3B,wBAAwB,EACxB,kIAAkI,EAClI,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,CAAC;aACL,IAAI,CAAC,gBAAgB,CAAC;aACtB,QAAQ,CAAC,mCAAmC,CAAC;QAChD,eAAe,EAAE,CAAC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;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC,CACF;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAwBnE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,QAcjD"}
|
package/dist/tools/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import balanceTools from './balance.js';
|
|
|
3
3
|
import contractTools from './contract.js';
|
|
4
4
|
import contractInfoTools from './contract-info.js';
|
|
5
5
|
import ensTools from './ens.js';
|
|
6
|
+
import gasTools from './gas.js';
|
|
6
7
|
import logTools from './logs.js';
|
|
7
8
|
import signatureTools from './signatures.js';
|
|
8
9
|
const allToolDefinitions = {
|
|
@@ -12,7 +13,8 @@ const allToolDefinitions = {
|
|
|
12
13
|
...balanceTools,
|
|
13
14
|
...logTools,
|
|
14
15
|
...advancedTools,
|
|
15
|
-
...ensTools
|
|
16
|
+
...ensTools,
|
|
17
|
+
...gasTools
|
|
16
18
|
};
|
|
17
19
|
// Register all tools with the MCP server
|
|
18
20
|
export function registerAllTools(server) {
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAGA,OAAO,aAAa,MAAM,eAAe,CAAA;AACzC,OAAO,YAAY,MAAM,cAAc,CAAA;AACvC,OAAO,aAAa,MAAM,eAAe,CAAA;AACzC,OAAO,iBAAiB,MAAM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G,aAAa;IAChB,GAAG,iBAAiB;IACpB,GAAG,YAAY;IACf,GAAG,QAAQ;IACX,GAAG,aAAa;IAChB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACH,CAAA;AAEV,yCAAyC;AACzC,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IAChD,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1D,MAAM,CAAC,YAAY,CACjB,IAAI,EACJ;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SAC/B,EACD,KAAK,EAAE,IAAS,EAAE,MAA8D,EAAE,EAAE;YAClF,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/tools/logs.d.ts
CHANGED
|
@@ -4,21 +4,21 @@ declare const _default: {
|
|
|
4
4
|
title: string;
|
|
5
5
|
description: string;
|
|
6
6
|
schema: z.ZodObject<{
|
|
7
|
-
chain: z.ZodEnum<["mainnet", "base", "
|
|
7
|
+
chain: z.ZodEnum<["mainnet", "arbitrum", "avalanche", "base", "bnb", "gnosis", "sonic", "optimism", "polygon", "zksync", "linea", "unichain", "localhost"]>;
|
|
8
8
|
eventAbi: z.ZodString;
|
|
9
9
|
address: z.ZodOptional<z.ZodString>;
|
|
10
10
|
fromBlock: z.ZodOptional<z.ZodString>;
|
|
11
11
|
toBlock: z.ZodOptional<z.ZodString>;
|
|
12
12
|
eventArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
chain: "mainnet" | "base" | "
|
|
14
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
15
15
|
eventAbi: string;
|
|
16
16
|
address?: string | undefined;
|
|
17
17
|
fromBlock?: string | undefined;
|
|
18
18
|
toBlock?: string | undefined;
|
|
19
19
|
eventArgs?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
|
|
20
20
|
}, {
|
|
21
|
-
chain: "mainnet" | "base" | "
|
|
21
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
22
22
|
eventAbi: string;
|
|
23
23
|
address?: string | undefined;
|
|
24
24
|
fromBlock?: string | undefined;
|
|
@@ -26,7 +26,7 @@ declare const _default: {
|
|
|
26
26
|
eventArgs?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
handler: (args: {
|
|
29
|
-
chain: "mainnet" | "base" | "
|
|
29
|
+
chain: "mainnet" | "arbitrum" | "avalanche" | "base" | "bnb" | "gnosis" | "sonic" | "optimism" | "polygon" | "zksync" | "linea" | "unichain" | "localhost";
|
|
30
30
|
eventAbi: string;
|
|
31
31
|
address?: string | undefined;
|
|
32
32
|
fromBlock?: string | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface Config {
|
|
|
11
11
|
customRpcUrls?: Record<string, string>;
|
|
12
12
|
hypersyncApiKey?: string;
|
|
13
13
|
}
|
|
14
|
-
export type ChainName = 'mainnet' | 'base' | '
|
|
14
|
+
export type ChainName = 'mainnet' | 'arbitrum' | 'avalanche' | 'base' | 'bnb' | 'gnosis' | 'sonic' | 'optimism' | 'polygon' | 'zksync' | 'linea' | 'unichain' | 'localhost';
|
|
15
15
|
export interface ToolResult {
|
|
16
16
|
[x: string]: unknown;
|
|
17
17
|
content: Array<{
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;CAChC;AAGD,MAAM,WAAW,MAAM;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAGD,MAAM,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;CAChC;AAGD,MAAM,WAAW,MAAM;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAGD,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,UAAU,GACV,WAAW,GACX,MAAM,GACN,KAAK,GACL,QAAQ,GACR,OAAO,GACP,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