@kasarlabs/transaction-mcp 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.
Files changed (34) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/bin/transaction-mcp.js +14 -0
  4. package/build/index.d.ts +2 -0
  5. package/build/index.js +88 -0
  6. package/build/index.js.map +1 -0
  7. package/build/lib/constant/index.d.ts +2 -0
  8. package/build/lib/constant/index.js +3 -0
  9. package/build/lib/constant/index.js.map +1 -0
  10. package/build/lib/dependances/types.d.ts +85 -0
  11. package/build/lib/dependances/types.js +51 -0
  12. package/build/lib/dependances/types.js.map +1 -0
  13. package/build/lib/types/estimate.d.ts +5 -0
  14. package/build/lib/types/estimate.js +2 -0
  15. package/build/lib/types/estimate.js.map +1 -0
  16. package/build/lib/types/index.d.ts +4 -0
  17. package/build/lib/types/index.js +2 -0
  18. package/build/lib/types/index.js.map +1 -0
  19. package/build/lib/types/simulateTransactionTypes.d.ts +53 -0
  20. package/build/lib/types/simulateTransactionTypes.js +2 -0
  21. package/build/lib/types/simulateTransactionTypes.js.map +1 -0
  22. package/build/lib/utils/TransactionMonitor.d.ts +11 -0
  23. package/build/lib/utils/TransactionMonitor.js +82 -0
  24. package/build/lib/utils/TransactionMonitor.js.map +1 -0
  25. package/build/lib/utils/outputSimulateTransaction.d.ts +19 -0
  26. package/build/lib/utils/outputSimulateTransaction.js +28 -0
  27. package/build/lib/utils/outputSimulateTransaction.js.map +1 -0
  28. package/build/schemas/index.d.ts +241 -0
  29. package/build/schemas/index.js +80 -0
  30. package/build/schemas/index.js.map +1 -0
  31. package/build/tools/simulateTransaction.d.ts +106 -0
  32. package/build/tools/simulateTransaction.js +117 -0
  33. package/build/tools/simulateTransaction.js.map +1 -0
  34. package/package.json +43 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kasar Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Snak - Transaction Plugin
2
+
3
+ The Transaction Plugin provides tools for simulating various types of transactions on the Starknet blockchain without actually executing them.
4
+
5
+ ## Features
6
+
7
+ This plugin adds the following simulation tools:
8
+
9
+ - **simulate_transaction**: Simulate an invoke transaction without executing it.
10
+ - **simulate_deploy_transaction**: Simulate a deploy transaction.
11
+ - **simulate_declare_transaction**: Simulate a declare transaction.
12
+ - **simulate_deploy_account_transaction**: Simulate a deploy account transaction.
13
+
14
+ ## Usage
15
+
16
+ The Transaction Plugin is used internally by the Starknet Agent and doesn't need to be called directly. When the agent is initialized, it automatically registers these tools, making them available for use.
17
+
18
+ ## Example
19
+
20
+ When asking the agent to perform transaction-related tasks, it will use the appropriate tool from this plugin:
21
+
22
+ ```
23
+ "What would happen if I called this contract function?" // Uses simulate_transaction
24
+ "Show me the result of deploying this contract without actually deploying it" // Uses simulate_deploy_transaction
25
+ ```
26
+
27
+ ## Development
28
+
29
+ To extend this plugin, add new tools in the `src/tools` directory and register them in the `registerTools` function in `src/tools/index.ts`.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const buildPath = join(__dirname, '..', 'build', 'index.js');
8
+
9
+ if (!existsSync(buildPath)) {
10
+ console.error('Build not found. Run: npm run build');
11
+ process.exit(1);
12
+ }
13
+
14
+ await import(buildPath);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export declare const RegisterToolInServer: () => Promise<void>;
package/build/index.js ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { registerToolsWithServer, getOnchainRead, } from '@kasarlabs/ask-starknet-core';
5
+ import dotenv from 'dotenv';
6
+ import { simulateInvokeTransaction, simulateDeployAccountTransaction, simulateDeployTransaction, simulateDeclareTransaction, } from './tools/simulateTransaction.js';
7
+ import { simulateInvokeTransactionSchema, simulateDeployAccountTransactionSchema, simulateDeployTransactionSchema, simulateDeclareTransactionSchema, } from './schemas/index.js';
8
+ dotenv.config();
9
+ const server = new McpServer({
10
+ name: 'starknet-transaction-mcp',
11
+ version: '0.0.1',
12
+ });
13
+ const registerTools = (TransactionToolRegistry) => {
14
+ TransactionToolRegistry.push({
15
+ name: 'simulate_transaction',
16
+ description: 'Simulate a transaction without executing it',
17
+ schema: simulateInvokeTransactionSchema,
18
+ execute: async (params) => {
19
+ const onchainRead = getOnchainRead();
20
+ return await simulateInvokeTransaction(onchainRead, params);
21
+ },
22
+ });
23
+ TransactionToolRegistry.push({
24
+ name: 'simulate_deploy_transaction',
25
+ description: 'Simulate Deploy transaction',
26
+ schema: simulateDeployTransactionSchema,
27
+ execute: async (params) => {
28
+ const onchainRead = getOnchainRead();
29
+ return await simulateDeployTransaction(onchainRead, params);
30
+ },
31
+ });
32
+ TransactionToolRegistry.push({
33
+ name: 'simulate_declare_transaction',
34
+ description: 'Simulate Declare transaction',
35
+ schema: simulateDeclareTransactionSchema,
36
+ execute: async (params) => {
37
+ const onchainRead = getOnchainRead();
38
+ return await simulateDeclareTransaction(onchainRead, params);
39
+ },
40
+ });
41
+ TransactionToolRegistry.push({
42
+ name: 'simulate_deploy_account_transaction',
43
+ description: 'Simulate Deploy Account transaction',
44
+ schema: simulateDeployAccountTransactionSchema,
45
+ execute: async (params) => {
46
+ const onchainRead = getOnchainRead();
47
+ return await simulateDeployAccountTransaction(onchainRead, params);
48
+ },
49
+ });
50
+ };
51
+ export const RegisterToolInServer = async () => {
52
+ const tools = [];
53
+ registerTools(tools);
54
+ await registerToolsWithServer(server, tools);
55
+ };
56
+ const checkEnv = () => {
57
+ const rpcUrl = process.env.STARKNET_RPC_URL;
58
+ const accountAddress = process.env.STARKNET_ACCOUNT_ADDRESS;
59
+ const privateKey = process.env.STARKNET_PRIVATE_KEY;
60
+ if (!rpcUrl) {
61
+ console.error('Missing required environment variable: STARKNET_RPC_URL');
62
+ return false;
63
+ }
64
+ if (!accountAddress) {
65
+ console.error('Missing required environment variable: STARKNET_ACCOUNT_ADDRESS');
66
+ return false;
67
+ }
68
+ if (!privateKey) {
69
+ console.error('Missing required environment variable: STARKNET_PRIVATE_KEY');
70
+ return false;
71
+ }
72
+ return true;
73
+ };
74
+ async function main() {
75
+ const transport = new StdioServerTransport();
76
+ if (!checkEnv()) {
77
+ console.error('Failed to initialize Transaction Server');
78
+ process.exit(1);
79
+ }
80
+ await RegisterToolInServer();
81
+ await server.connect(transport);
82
+ console.error('Starknet Transaction MCP Server running on stdio');
83
+ }
84
+ main().catch((error) => {
85
+ console.error('Fatal error in main():', error);
86
+ process.exit(1);
87
+ });
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 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AE,CAAC;QACpB,OAAO,CAAC,KAAK,CACX,iEAAiE,CAClE,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CACX,6DAA6D,CAC9D,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,oBAAoB,EAAE,CAAC;IAC7B,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACpE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_GUARDIAN = "0x0";
2
+ export declare const DEFAULT_NONCE = "0x0";
@@ -0,0 +1,3 @@
1
+ export const DEFAULT_GUARDIAN = '0x0';
2
+ export const DEFAULT_NONCE = '0x0';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/constant/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { RpcProvider } from 'starknet';
2
+ import { SystemMessage } from '@langchain/core/messages';
3
+ import { z as Zod } from 'zod';
4
+ export interface StarknetTool<P = unknown> {
5
+ name: string;
6
+ plugins: string;
7
+ description: string;
8
+ schema?: Zod.AnyZodObject;
9
+ responseFormat?: string;
10
+ execute: (agent: SnakAgentInterface, params: P, plugins_manager?: any) => Promise<unknown>;
11
+ }
12
+ export interface SignatureTool<P = any> {
13
+ name: string;
14
+ categorie?: string;
15
+ description: string;
16
+ schema?: object;
17
+ execute: (params: P) => Promise<unknown>;
18
+ }
19
+ export declare enum AgentMode {
20
+ INTERACTIVE = "interactive",
21
+ AUTONOMOUS = "autonomous",
22
+ HYBRID = "hybrid"
23
+ }
24
+ export interface RawAgentConfig {
25
+ name: string;
26
+ group: string;
27
+ description: string;
28
+ lore: string[];
29
+ objectives: string[];
30
+ knowledge: string[];
31
+ interval: number;
32
+ plugins: string[];
33
+ memory: MemoryConfig;
34
+ rag?: RagConfig;
35
+ mcpServers?: Record<string, any>;
36
+ mode: AgentMode;
37
+ }
38
+ export interface MemoryConfig {
39
+ enabled?: boolean;
40
+ shortTermMemorySize?: number;
41
+ memorySize?: number;
42
+ maxIterations?: number;
43
+ embeddingModel?: string;
44
+ }
45
+ export interface RagConfig {
46
+ enabled?: boolean;
47
+ topK?: number;
48
+ embeddingModel?: string;
49
+ }
50
+ export interface AgentConfig {
51
+ id: string;
52
+ name: string;
53
+ group: string;
54
+ description: string;
55
+ interval: number;
56
+ chatId: string;
57
+ plugins: string[];
58
+ memory: MemoryConfig;
59
+ rag?: RagConfig;
60
+ mcpServers?: Record<string, any>;
61
+ mode: AgentMode;
62
+ maxIterations: number;
63
+ prompt: SystemMessage;
64
+ }
65
+ export interface DatabaseCredentials {
66
+ host: string;
67
+ port: number;
68
+ user: string;
69
+ password: string;
70
+ database: string;
71
+ }
72
+ export interface SnakAgentInterface {
73
+ getAccountCredentials: () => {
74
+ accountPublicKey: string;
75
+ accountPrivateKey: string;
76
+ };
77
+ getDatabaseCredentials: () => DatabaseCredentials;
78
+ getSignature: () => {
79
+ signature: string;
80
+ };
81
+ getProvider: () => RpcProvider;
82
+ getAgentConfig: () => AgentConfig;
83
+ }
84
+ import winston from 'winston';
85
+ export declare const logger: winston.Logger;
@@ -0,0 +1,51 @@
1
+ export var AgentMode;
2
+ (function (AgentMode) {
3
+ AgentMode["INTERACTIVE"] = "interactive";
4
+ AgentMode["AUTONOMOUS"] = "autonomous";
5
+ AgentMode["HYBRID"] = "hybrid";
6
+ })(AgentMode || (AgentMode = {}));
7
+ import winston from 'winston';
8
+ const levels = {
9
+ error: 0,
10
+ warn: 1,
11
+ info: 2,
12
+ http: 3,
13
+ debug: 4,
14
+ };
15
+ const colors = {
16
+ error: 'red',
17
+ warn: 'yellow',
18
+ info: 'green',
19
+ http: 'magenta',
20
+ debug: 'blue',
21
+ };
22
+ winston.addColors(colors);
23
+ const level = () => {
24
+ if (process.env.LOG_LEVEL) {
25
+ return process.env.LOG_LEVEL.toLowerCase();
26
+ }
27
+ const env = process.env.NODE_ENV || 'production';
28
+ return env === 'development' ? 'debug' : 'info';
29
+ };
30
+ const format = winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.colorize({ all: true }), winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`));
31
+ let transports;
32
+ try {
33
+ transports = [
34
+ new winston.transports.Console(),
35
+ new winston.transports.File({
36
+ filename: 'logs/error.log',
37
+ level: 'error',
38
+ }),
39
+ new winston.transports.File({ filename: 'logs/combined.log' }),
40
+ ];
41
+ }
42
+ catch (error) {
43
+ transports = [new winston.transports.Console()];
44
+ }
45
+ export const logger = winston.createLogger({
46
+ level: level(),
47
+ levels,
48
+ format,
49
+ transports,
50
+ });
51
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/dependances/types.ts"],"names":[],"mappings":"AAqCA,MAAM,CAAN,IAAY,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CAC7D,CACF,CAAC;AACF,IAAI,UAAU,CAAC;AACf,IAAI,CAAC;IACH,UAAU,GAAG;QACX,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE;QAEhC,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,QAAQ,EAAE,gBAAgB;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;QAEF,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACzC,KAAK,EAAE,KAAK,EAAE;IACd,MAAM;IACN,MAAM;IACN,UAAU;CACX,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DeployAccountContractPayload } from 'starknet';
2
+ export type EstimateAccountDeployFeeParams = {
3
+ accountAddress: string;
4
+ payloads: DeployAccountContractPayload[];
5
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=estimate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.js","sourceRoot":"","sources":["../../../src/lib/types/estimate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { ProviderInterface } from 'starknet';
2
+ export interface BaseUtilityClass {
3
+ provider: ProviderInterface;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ import { TransactionType, BigNumberish, RawArgs, CompiledContract, CairoAssembly, DeployAccountContractPayload, UniversalDeployerContractPayload, Call, DeclareContractPayload } from 'starknet';
2
+ export type InvocationInvokePayload = {
3
+ contractAddress: string;
4
+ entrypoint: string;
5
+ calldata: string[];
6
+ };
7
+ export type Invocation_Invoke = {
8
+ type: typeof TransactionType.INVOKE;
9
+ payload: InvocationInvokePayload;
10
+ };
11
+ export type SimulateInvokeTransactionParams = {
12
+ accountAddress: string;
13
+ payloads: Call[];
14
+ };
15
+ export type Invocation_Deploy_Account_Payload = {
16
+ classHash: string;
17
+ constructorCalldata?: RawArgs;
18
+ addressSalt?: BigNumberish;
19
+ contractAddress?: string;
20
+ };
21
+ export type Invocation_Deploy_Account = {
22
+ type: typeof TransactionType.DEPLOY_ACCOUNT;
23
+ payload: Invocation_Deploy_Account_Payload;
24
+ };
25
+ export type SimulateDeployTransactionAccountParams = {
26
+ accountAddress: string;
27
+ payloads: DeployAccountContractPayload[];
28
+ };
29
+ export type Invocation_Deploy_Payload = {
30
+ classHash: BigNumberish;
31
+ salt?: string;
32
+ unique?: boolean;
33
+ constructorCalldata?: RawArgs;
34
+ };
35
+ export type Invocation_Deploy = {
36
+ type: typeof TransactionType.DEPLOY;
37
+ payload: Invocation_Deploy_Payload;
38
+ };
39
+ export type SimulateDeployTransactionParams = {
40
+ accountAddress: string;
41
+ payloads: UniversalDeployerContractPayload[];
42
+ };
43
+ export type Invocation_Declare = {
44
+ type: typeof TransactionType.DECLARE;
45
+ payload: DeclareContractPayload;
46
+ };
47
+ export type SimulateDeclareTransactionAccountParams = {
48
+ accountAddress: string;
49
+ contract: string | CompiledContract;
50
+ classHash?: string;
51
+ casm?: CairoAssembly;
52
+ compiledClassHash?: string;
53
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=simulateTransactionTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateTransactionTypes.js","sourceRoot":"","sources":["../../../src/lib/types/simulateTransactionTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { TransactionReceipt, TransactionStatus } from 'starknet';
2
+ import { BaseUtilityClass } from '../types/index.js';
3
+ export declare class TransactionMonitor implements BaseUtilityClass {
4
+ provider: any;
5
+ private readonly pollingInterval;
6
+ constructor(provider: any, pollingInterval?: number);
7
+ waitForTransaction(txHash: string, callback?: (status: TransactionStatus) => void): Promise<TransactionReceipt>;
8
+ getTransactionEvents(txHash: string): Promise<Event[]>;
9
+ watchEvents(fromBlock: number, toBlock: number | "latest" | undefined, callback: (events: Event[]) => void): Promise<void>;
10
+ getTransactionStatus(txHash: string): Promise<TransactionStatus>;
11
+ }
@@ -0,0 +1,82 @@
1
+ export class TransactionMonitor {
2
+ constructor(provider, pollingInterval = 5000) {
3
+ this.provider = provider;
4
+ this.pollingInterval = pollingInterval;
5
+ }
6
+ async waitForTransaction(txHash, callback) {
7
+ let receipt;
8
+ while (true) {
9
+ try {
10
+ receipt = await this.provider.getTransactionReceipt(txHash);
11
+ if (callback) {
12
+ const status = await this.provider.getTransactionStatus(txHash);
13
+ callback(status);
14
+ }
15
+ if (receipt.finality_status === 'ACCEPTED_ON_L2' ||
16
+ receipt.finality_status === 'ACCEPTED_ON_L1') {
17
+ break;
18
+ }
19
+ if (receipt.execution_status === 'REVERTED') {
20
+ throw new Error(`Transaction ${txHash} was reverted`);
21
+ }
22
+ await new Promise((resolve) => setTimeout(resolve, this.pollingInterval));
23
+ }
24
+ catch (error) {
25
+ if (error.message.includes('Transaction hash not found')) {
26
+ await new Promise((resolve) => setTimeout(resolve, this.pollingInterval));
27
+ continue;
28
+ }
29
+ throw error;
30
+ }
31
+ }
32
+ return receipt;
33
+ }
34
+ async getTransactionEvents(txHash) {
35
+ try {
36
+ const receipt = await this.provider.getTransactionReceipt(txHash);
37
+ return receipt.events || [];
38
+ }
39
+ catch (error) {
40
+ throw new Error(`Failed to get transaction events: ${error.message}`);
41
+ }
42
+ }
43
+ async watchEvents(fromBlock, toBlock = 'latest', callback) {
44
+ let currentBlock = fromBlock;
45
+ while (true) {
46
+ try {
47
+ const latestBlock = toBlock === 'latest' ? await this.provider.getBlockNumber() : toBlock;
48
+ if (currentBlock > latestBlock) {
49
+ break;
50
+ }
51
+ const block = await this.provider.getBlockWithTxs(currentBlock);
52
+ const events = [];
53
+ for (const tx of block.transactions) {
54
+ if (tx.transaction_hash) {
55
+ const receipt = await this.provider.getTransactionReceipt(tx.transaction_hash);
56
+ if (receipt.events) {
57
+ events.push(...receipt.events);
58
+ }
59
+ }
60
+ }
61
+ if (events.length > 0) {
62
+ callback(events);
63
+ }
64
+ currentBlock++;
65
+ await new Promise((resolve) => setTimeout(resolve, this.pollingInterval));
66
+ }
67
+ catch (error) {
68
+ console.error('Error watching events:', error);
69
+ await new Promise((resolve) => setTimeout(resolve, this.pollingInterval));
70
+ }
71
+ }
72
+ }
73
+ async getTransactionStatus(txHash) {
74
+ try {
75
+ return await this.provider.getTransactionStatus(txHash);
76
+ }
77
+ catch (error) {
78
+ throw new Error(`Failed to get transaction status: ${error.message}`);
79
+ }
80
+ }
81
+ }
82
+ //# sourceMappingURL=TransactionMonitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionMonitor.js","sourceRoot":"","sources":["../../../src/lib/utils/TransactionMonitor.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,kBAAkB;IAC7B,YACS,QAAa,EACH,kBAA0B,IAAI;QADxC,aAAQ,GAAR,QAAQ,CAAK;QACH,oBAAe,GAAf,eAAe,CAAe;IAC9C,CAAC;IAEJ,KAAK,CAAC,kBAAkB,CACtB,MAAc,EACd,QAA8C;QAE9C,IAAI,OAA2B,CAAC;QAEhC,OAAO,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;gBAE5D,IAAI,QAAQ,EAAE,CAAC;oBACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;oBAChE,QAAQ,CA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BAAoB,CAAC,MAAc;QACvC,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { SimulateTransactionResponse } from 'starknet';
2
+ export declare const TransactionReponseFormat: (transactionResponse: SimulateTransactionResponse) => Array<{
3
+ transaction_number: number;
4
+ fee_estimation: {
5
+ title: string;
6
+ details: any;
7
+ };
8
+ resource_bounds: {
9
+ l1_gas: {
10
+ max_amount: string;
11
+ max_price_per_unit: string;
12
+ };
13
+ l2_gas: {
14
+ max_amount: string;
15
+ max_price_per_unit: string;
16
+ };
17
+ };
18
+ suggested_max_fee: string;
19
+ }>;
@@ -0,0 +1,28 @@
1
+ export const TransactionReponseFormat = (transactionResponse) => {
2
+ const transactionDetails = transactionResponse.map((transaction, index) => {
3
+ const feeData = transaction.fee_estimation;
4
+ const resourceBounds = transaction.resourceBounds;
5
+ return {
6
+ transaction_number: index + 1,
7
+ fee_estimation: {
8
+ title: 'Fee Estimation Breakdown',
9
+ details: {
10
+ ...feeData,
11
+ },
12
+ },
13
+ resource_bounds: {
14
+ l1_gas: {
15
+ max_amount: resourceBounds.l1_gas.max_amount,
16
+ max_price_per_unit: resourceBounds.l1_gas.max_price_per_unit,
17
+ },
18
+ l2_gas: {
19
+ max_amount: resourceBounds.l2_gas.max_amount,
20
+ max_price_per_unit: resourceBounds.l2_gas.max_price_per_unit,
21
+ },
22
+ },
23
+ suggested_max_fee: transaction.suggestedMaxFee.toString(),
24
+ };
25
+ });
26
+ return transactionDetails;
27
+ };
28
+ //# sourceMappingURL=outputSimulateTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputSimulateTransaction.js","sourceRoot":"","sources":["../../../src/lib/utils/outputSimulateTransaction.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,mBAAgD,EAkB/C,EAAE;IACH,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;QACxE,MAAM,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC;QAC3C,MAAM,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;QAElD,OAAO;YACL,kBAAkB,EAAE,KAAK,GAAG,CAAC;YAE7B,cAAc,EAAE;gBACd,KAAK,EAAE,0BAA0B;gBACjC,OAAO,EAAE;oBACP,GAAG,OAAO;iBACX;aACF;YAED,eAAe,EAAE;gBACf,MAAM,EAAE;oBACN,UAAU,EAAE,cAAc,CAAC,MAAM,CAAC,UAAU;oBAC5C,kBAAkB,EAAE,cAAc,CAAC,MAAM,CAAC,kBAAkB;iBAC7D;gBACD,MAAM,EAAE;oBACN,UAAU,EAAE,cAAc,CAAC,MAAM,CAAC,UAAU;oBAC5C,kBAAkB,EAAE,cAAc,CAAC,MAAM,CAAC,kBAAkB;iBAC7D;aACF;YAED,iBAAiB,EAAE,WAAW,CAAC,eAAe,CAAC,QAAQ,EAAE;SAC1D,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC"}
@@ -0,0 +1,241 @@
1
+ import { z } from 'zod';
2
+ export declare const declareContractSchema: z.ZodObject<{
3
+ contract: z.ZodAny;
4
+ classHash: z.ZodOptional<z.ZodString>;
5
+ compiledClassHash: z.ZodOptional<z.ZodString>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ classHash?: string | undefined;
8
+ contract?: any;
9
+ compiledClassHash?: string | undefined;
10
+ }, {
11
+ classHash?: string | undefined;
12
+ contract?: any;
13
+ compiledClassHash?: string | undefined;
14
+ }>;
15
+ export declare const simulateInvokeTransactionSchema: z.ZodObject<{
16
+ accountAddress: z.ZodString;
17
+ payloads: z.ZodArray<z.ZodObject<{
18
+ contractAddress: z.ZodString;
19
+ entrypoint: z.ZodString;
20
+ calldata: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ contractAddress: string;
23
+ entrypoint: string;
24
+ calldata?: string[] | Record<string, any> | undefined;
25
+ }, {
26
+ contractAddress: string;
27
+ entrypoint: string;
28
+ calldata?: string[] | Record<string, any> | undefined;
29
+ }>, "many">;
30
+ }, "strip", z.ZodTypeAny, {
31
+ accountAddress: string;
32
+ payloads: {
33
+ contractAddress: string;
34
+ entrypoint: string;
35
+ calldata?: string[] | Record<string, any> | undefined;
36
+ }[];
37
+ }, {
38
+ accountAddress: string;
39
+ payloads: {
40
+ contractAddress: string;
41
+ entrypoint: string;
42
+ calldata?: string[] | Record<string, any> | undefined;
43
+ }[];
44
+ }>;
45
+ export declare const simulateDeployAccountTransactionSchema: z.ZodObject<{
46
+ accountAddress: z.ZodString;
47
+ payloads: z.ZodArray<z.ZodObject<{
48
+ classHash: z.ZodString;
49
+ constructorCalldata: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
50
+ addressSalt: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>>;
51
+ contractAddressSchema: z.ZodOptional<z.ZodString>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ classHash: string;
54
+ addressSalt?: string | number | bigint | undefined;
55
+ constructorCalldata?: string[] | Record<string, any> | undefined;
56
+ contractAddressSchema?: string | undefined;
57
+ }, {
58
+ classHash: string;
59
+ addressSalt?: string | number | bigint | undefined;
60
+ constructorCalldata?: string[] | Record<string, any> | undefined;
61
+ contractAddressSchema?: string | undefined;
62
+ }>, "many">;
63
+ }, "strip", z.ZodTypeAny, {
64
+ accountAddress: string;
65
+ payloads: {
66
+ classHash: string;
67
+ addressSalt?: string | number | bigint | undefined;
68
+ constructorCalldata?: string[] | Record<string, any> | undefined;
69
+ contractAddressSchema?: string | undefined;
70
+ }[];
71
+ }, {
72
+ accountAddress: string;
73
+ payloads: {
74
+ classHash: string;
75
+ addressSalt?: string | number | bigint | undefined;
76
+ constructorCalldata?: string[] | Record<string, any> | undefined;
77
+ contractAddressSchema?: string | undefined;
78
+ }[];
79
+ }>;
80
+ export declare const simulateDeployTransactionSchema: z.ZodObject<{
81
+ accountAddress: z.ZodString;
82
+ payloads: z.ZodArray<z.ZodObject<{
83
+ classHash: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>;
84
+ addressSalt: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>>;
85
+ unique: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
86
+ constructorCalldata: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
87
+ }, "strip", z.ZodTypeAny, {
88
+ classHash: string | number | bigint;
89
+ addressSalt?: string | number | bigint | undefined;
90
+ unique?: string | boolean | undefined;
91
+ constructorCalldata?: string[] | Record<string, any> | undefined;
92
+ }, {
93
+ classHash: string | number | bigint;
94
+ addressSalt?: string | number | bigint | undefined;
95
+ unique?: string | boolean | undefined;
96
+ constructorCalldata?: string[] | Record<string, any> | undefined;
97
+ }>, "many">;
98
+ }, "strip", z.ZodTypeAny, {
99
+ accountAddress: string;
100
+ payloads: {
101
+ classHash: string | number | bigint;
102
+ addressSalt?: string | number | bigint | undefined;
103
+ unique?: string | boolean | undefined;
104
+ constructorCalldata?: string[] | Record<string, any> | undefined;
105
+ }[];
106
+ }, {
107
+ accountAddress: string;
108
+ payloads: {
109
+ classHash: string | number | bigint;
110
+ addressSalt?: string | number | bigint | undefined;
111
+ unique?: string | boolean | undefined;
112
+ constructorCalldata?: string[] | Record<string, any> | undefined;
113
+ }[];
114
+ }>;
115
+ export declare const simulateDeclareTransactionSchema: z.ZodObject<{
116
+ accountAddress: z.ZodString;
117
+ contract: z.ZodUnion<[z.ZodString, z.ZodObject<{
118
+ program: z.ZodAny;
119
+ entry_points_by_type: z.ZodAny;
120
+ }, "strip", z.ZodTypeAny, {
121
+ program?: any;
122
+ entry_points_by_type?: any;
123
+ }, {
124
+ program?: any;
125
+ entry_points_by_type?: any;
126
+ }>]>;
127
+ classHash: z.ZodOptional<z.ZodString>;
128
+ casm: z.ZodOptional<z.ZodObject<{
129
+ prime: z.ZodString;
130
+ compiler_version: z.ZodString;
131
+ bytecode: z.ZodArray<z.ZodString, "many">;
132
+ hints: z.ZodRecord<z.ZodString, z.ZodAny>;
133
+ entry_points_by_type: z.ZodObject<{
134
+ CONSTRUCTOR: z.ZodArray<z.ZodAny, "many">;
135
+ EXTERNAL: z.ZodArray<z.ZodAny, "many">;
136
+ L1_HANDLER: z.ZodArray<z.ZodAny, "many">;
137
+ }, "strip", z.ZodTypeAny, {
138
+ CONSTRUCTOR: any[];
139
+ EXTERNAL: any[];
140
+ L1_HANDLER: any[];
141
+ }, {
142
+ CONSTRUCTOR: any[];
143
+ EXTERNAL: any[];
144
+ L1_HANDLER: any[];
145
+ }>;
146
+ }, "strip", z.ZodTypeAny, {
147
+ entry_points_by_type: {
148
+ CONSTRUCTOR: any[];
149
+ EXTERNAL: any[];
150
+ L1_HANDLER: any[];
151
+ };
152
+ prime: string;
153
+ compiler_version: string;
154
+ bytecode: string[];
155
+ hints: Record<string, any>;
156
+ }, {
157
+ entry_points_by_type: {
158
+ CONSTRUCTOR: any[];
159
+ EXTERNAL: any[];
160
+ L1_HANDLER: any[];
161
+ };
162
+ prime: string;
163
+ compiler_version: string;
164
+ bytecode: string[];
165
+ hints: Record<string, any>;
166
+ }>>;
167
+ compiledClassHash: z.ZodOptional<z.ZodString>;
168
+ }, "strip", z.ZodTypeAny, {
169
+ accountAddress: string;
170
+ contract: string | {
171
+ program?: any;
172
+ entry_points_by_type?: any;
173
+ };
174
+ classHash?: string | undefined;
175
+ casm?: {
176
+ entry_points_by_type: {
177
+ CONSTRUCTOR: any[];
178
+ EXTERNAL: any[];
179
+ L1_HANDLER: any[];
180
+ };
181
+ prime: string;
182
+ compiler_version: string;
183
+ bytecode: string[];
184
+ hints: Record<string, any>;
185
+ } | undefined;
186
+ compiledClassHash?: string | undefined;
187
+ }, {
188
+ accountAddress: string;
189
+ contract: string | {
190
+ program?: any;
191
+ entry_points_by_type?: any;
192
+ };
193
+ classHash?: string | undefined;
194
+ casm?: {
195
+ entry_points_by_type: {
196
+ CONSTRUCTOR: any[];
197
+ EXTERNAL: any[];
198
+ L1_HANDLER: any[];
199
+ };
200
+ prime: string;
201
+ compiler_version: string;
202
+ bytecode: string[];
203
+ hints: Record<string, any>;
204
+ } | undefined;
205
+ compiledClassHash?: string | undefined;
206
+ }>;
207
+ export declare const estimateAccountDeployFeeSchema: z.ZodObject<{
208
+ accountAddress: z.ZodString;
209
+ payloads: z.ZodArray<z.ZodObject<{
210
+ classHash: z.ZodString;
211
+ constructorCalldata: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodRecord<z.ZodString, z.ZodAny>]>>;
212
+ addressSalt: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>>;
213
+ contractAddressSchema: z.ZodOptional<z.ZodString>;
214
+ }, "strip", z.ZodTypeAny, {
215
+ classHash: string;
216
+ addressSalt?: string | number | bigint | undefined;
217
+ constructorCalldata?: string[] | Record<string, any> | undefined;
218
+ contractAddressSchema?: string | undefined;
219
+ }, {
220
+ classHash: string;
221
+ addressSalt?: string | number | bigint | undefined;
222
+ constructorCalldata?: string[] | Record<string, any> | undefined;
223
+ contractAddressSchema?: string | undefined;
224
+ }>, "many">;
225
+ }, "strip", z.ZodTypeAny, {
226
+ accountAddress: string;
227
+ payloads: {
228
+ classHash: string;
229
+ addressSalt?: string | number | bigint | undefined;
230
+ constructorCalldata?: string[] | Record<string, any> | undefined;
231
+ contractAddressSchema?: string | undefined;
232
+ }[];
233
+ }, {
234
+ accountAddress: string;
235
+ payloads: {
236
+ classHash: string;
237
+ addressSalt?: string | number | bigint | undefined;
238
+ constructorCalldata?: string[] | Record<string, any> | undefined;
239
+ contractAddressSchema?: string | undefined;
240
+ }[];
241
+ }>;
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ export const declareContractSchema = z.object({
3
+ contract: z.any().describe('The compiled contract to be declared'),
4
+ classHash: z.string().optional().describe('Optional pre-computed class hash'),
5
+ compiledClassHash: z
6
+ .string()
7
+ .optional()
8
+ .describe('Optional compiled class hash for Cairo 1 contracts'),
9
+ });
10
+ const callSchema = z.object({
11
+ contractAddress: z.string().describe('The contract address'),
12
+ entrypoint: z.string().describe('The entrypoint'),
13
+ calldata: z.array(z.string()).or(z.record(z.any())).optional(),
14
+ });
15
+ export const simulateInvokeTransactionSchema = z.object({
16
+ accountAddress: z.string().describe('Account Address/public key'),
17
+ payloads: z.array(callSchema),
18
+ });
19
+ const PayloadDeployAccountSchema = z.object({
20
+ classHash: z.string().describe('The class Hash Address'),
21
+ constructorCalldata: z.array(z.string()).or(z.record(z.any())).optional(),
22
+ addressSalt: z
23
+ .union([z.string().regex(/^0x[0-9a-fA-F]+$/), z.number(), z.bigint()])
24
+ .optional(),
25
+ contractAddressSchema: z.string().describe('ContractAddress').optional(),
26
+ });
27
+ export const simulateDeployAccountTransactionSchema = z.object({
28
+ accountAddress: z.string().describe('Account Address'),
29
+ payloads: z.array(PayloadDeployAccountSchema),
30
+ });
31
+ const PayloadDeploySchema = z.object({
32
+ classHash: z.union([
33
+ z.string().regex(/^0x[0-9a-fA-F]+$/),
34
+ z.number(),
35
+ z.bigint().describe('The class Hash Address'),
36
+ ]),
37
+ addressSalt: z
38
+ .union([z.string().regex(/^0x[0-9a-fA-F]+$/), z.number(), z.bigint()])
39
+ .optional(),
40
+ unique: z
41
+ .union([
42
+ z.string().regex(/^0x[0-9a-fA-F]+$/),
43
+ z.boolean().describe('unique true or false'),
44
+ ])
45
+ .optional(),
46
+ constructorCalldata: z.array(z.string()).or(z.record(z.any())).optional(),
47
+ });
48
+ export const simulateDeployTransactionSchema = z.object({
49
+ accountAddress: z.string().describe('Account Address'),
50
+ payloads: z.array(PayloadDeploySchema),
51
+ });
52
+ const cairoAssemblySchema = z.object({
53
+ prime: z.string(),
54
+ compiler_version: z.string(),
55
+ bytecode: z.array(z.string()),
56
+ hints: z.record(z.any()),
57
+ entry_points_by_type: z.object({
58
+ CONSTRUCTOR: z.array(z.any()),
59
+ EXTERNAL: z.array(z.any()),
60
+ L1_HANDLER: z.array(z.any()),
61
+ }),
62
+ });
63
+ const compiledContractSchema = z.object({
64
+ program: z.any(),
65
+ entry_points_by_type: z.any(),
66
+ });
67
+ export const simulateDeclareTransactionSchema = z.object({
68
+ accountAddress: z.string().describe('Account address'),
69
+ contract: z
70
+ .union([z.string(), compiledContractSchema])
71
+ .describe('Contract data'),
72
+ classHash: z.string().optional().describe('Class hash of the contract'),
73
+ casm: cairoAssemblySchema.optional().describe('Cairo assembly data'),
74
+ compiledClassHash: z.string().optional().describe('Compiled class hash'),
75
+ });
76
+ export const estimateAccountDeployFeeSchema = z.object({
77
+ accountAddress: z.string().describe('Account Address'),
78
+ payloads: z.array(PayloadDeployAccountSchema),
79
+ });
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;IAClE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC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4BAA4B,CAAC;IACvE,IAAI,EAAE,mBAAmB,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACpE,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;CACzE,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACtD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC;CAC9C,CAAC,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { SimulateDeployTransactionAccountParams, SimulateInvokeTransactionParams, SimulateDeployTransactionParams, SimulateDeclareTransactionAccountParams } from '../lib/types/simulateTransactionTypes.js';
2
+ import { onchainWrite } from '@kasarlabs/ask-starknet-core';
3
+ export declare const simulateInvokeTransaction: (env: onchainWrite, params: SimulateInvokeTransactionParams) => Promise<{
4
+ status: string;
5
+ transaction_output: {
6
+ transaction_number: number;
7
+ fee_estimation: {
8
+ title: string;
9
+ details: any;
10
+ };
11
+ resource_bounds: {
12
+ l1_gas: {
13
+ max_amount: string;
14
+ max_price_per_unit: string;
15
+ };
16
+ l2_gas: {
17
+ max_amount: string;
18
+ max_price_per_unit: string;
19
+ };
20
+ };
21
+ suggested_max_fee: string;
22
+ }[];
23
+ error?: undefined;
24
+ } | {
25
+ status: string;
26
+ error: string;
27
+ transaction_output?: undefined;
28
+ }>;
29
+ export declare const simulateDeployAccountTransaction: (env: onchainWrite, params: SimulateDeployTransactionAccountParams) => Promise<{
30
+ status: string;
31
+ transaction_output: {
32
+ transaction_number: number;
33
+ fee_estimation: {
34
+ title: string;
35
+ details: any;
36
+ };
37
+ resource_bounds: {
38
+ l1_gas: {
39
+ max_amount: string;
40
+ max_price_per_unit: string;
41
+ };
42
+ l2_gas: {
43
+ max_amount: string;
44
+ max_price_per_unit: string;
45
+ };
46
+ };
47
+ suggested_max_fee: string;
48
+ }[];
49
+ error?: undefined;
50
+ } | {
51
+ status: string;
52
+ error: string;
53
+ transaction_output?: undefined;
54
+ }>;
55
+ export declare const simulateDeployTransaction: (env: onchainWrite, params: SimulateDeployTransactionParams) => Promise<{
56
+ status: string;
57
+ transaction_output: {
58
+ transaction_number: number;
59
+ fee_estimation: {
60
+ title: string;
61
+ details: any;
62
+ };
63
+ resource_bounds: {
64
+ l1_gas: {
65
+ max_amount: string;
66
+ max_price_per_unit: string;
67
+ };
68
+ l2_gas: {
69
+ max_amount: string;
70
+ max_price_per_unit: string;
71
+ };
72
+ };
73
+ suggested_max_fee: string;
74
+ }[];
75
+ error?: undefined;
76
+ } | {
77
+ status: string;
78
+ error: string;
79
+ transaction_output?: undefined;
80
+ }>;
81
+ export declare const simulateDeclareTransaction: (env: onchainWrite, params: SimulateDeclareTransactionAccountParams) => Promise<{
82
+ status: string;
83
+ transaction_output: {
84
+ transaction_number: number;
85
+ fee_estimation: {
86
+ title: string;
87
+ details: any;
88
+ };
89
+ resource_bounds: {
90
+ l1_gas: {
91
+ max_amount: string;
92
+ max_price_per_unit: string;
93
+ };
94
+ l2_gas: {
95
+ max_amount: string;
96
+ max_price_per_unit: string;
97
+ };
98
+ };
99
+ suggested_max_fee: string;
100
+ }[];
101
+ error?: undefined;
102
+ } | {
103
+ status: string;
104
+ error: string;
105
+ transaction_output?: undefined;
106
+ }>;
@@ -0,0 +1,117 @@
1
+ import { TransactionType } from 'starknet';
2
+ import { TransactionReponseFormat } from '../lib/utils/outputSimulateTransaction.js';
3
+ import { DEFAULT_NONCE } from '../lib/constant/index.js';
4
+ export const simulateInvokeTransaction = async (env, params) => {
5
+ try {
6
+ const account = env.account;
7
+ const invocations = params.payloads.map((payload) => {
8
+ return {
9
+ type: TransactionType.INVOKE,
10
+ payload: {
11
+ contractAddress: payload.contractAddress,
12
+ entrypoint: payload.entrypoint,
13
+ calldata: payload.calldata,
14
+ },
15
+ };
16
+ });
17
+ const simulate_transaction = await account.simulateTransaction(invocations);
18
+ const transaction_output = TransactionReponseFormat(simulate_transaction);
19
+ return {
20
+ status: 'success',
21
+ transaction_output: transaction_output,
22
+ };
23
+ }
24
+ catch (error) {
25
+ return {
26
+ status: 'failure',
27
+ error: error instanceof Error ? error.message : 'Unknown error',
28
+ };
29
+ }
30
+ };
31
+ export const simulateDeployAccountTransaction = async (env, params) => {
32
+ try {
33
+ const account = env.account;
34
+ const invocations = params.payloads.map((payload) => {
35
+ return {
36
+ type: TransactionType.DEPLOY_ACCOUNT,
37
+ payload: {
38
+ classHash: payload.classHash,
39
+ constructorCalldata: payload.constructorCalldata ?? [],
40
+ addressSalt: payload.addressSalt,
41
+ contractAddress: payload.contractAddress,
42
+ },
43
+ };
44
+ });
45
+ const simulate_transaction = await account.simulateTransaction(invocations, {
46
+ nonce: DEFAULT_NONCE,
47
+ });
48
+ const transaction_output = TransactionReponseFormat(simulate_transaction);
49
+ return {
50
+ status: 'success',
51
+ transaction_output: transaction_output,
52
+ };
53
+ }
54
+ catch (error) {
55
+ return {
56
+ status: 'failure',
57
+ error: error instanceof Error ? error.message : 'Unknown error',
58
+ };
59
+ }
60
+ };
61
+ export const simulateDeployTransaction = async (env, params) => {
62
+ try {
63
+ const account = env.account;
64
+ const invocations = params.payloads.map((payload) => {
65
+ return {
66
+ type: TransactionType.DEPLOY,
67
+ payload: {
68
+ classHash: payload.classHash,
69
+ salt: payload.salt,
70
+ constructorCalldata: payload.constructorCalldata,
71
+ unique: payload.unique,
72
+ },
73
+ };
74
+ });
75
+ const simulate_transaction = await account.simulateTransaction(invocations);
76
+ const transaction_output = TransactionReponseFormat(simulate_transaction);
77
+ return {
78
+ status: 'success',
79
+ transaction_output: transaction_output,
80
+ };
81
+ }
82
+ catch (error) {
83
+ return {
84
+ status: 'failure',
85
+ error: error instanceof Error ? error.message : 'Unknown error',
86
+ };
87
+ }
88
+ };
89
+ export const simulateDeclareTransaction = async (env, params) => {
90
+ try {
91
+ const account = env.account;
92
+ const invocations = [
93
+ {
94
+ type: TransactionType.DECLARE,
95
+ payload: {
96
+ contract: params.contract,
97
+ classHash: params.classHash,
98
+ casm: params.casm,
99
+ compiledClassHash: params.compiledClassHash,
100
+ },
101
+ },
102
+ ];
103
+ const simulate_transaction = await account.simulateTransaction(invocations);
104
+ const transaction_output = TransactionReponseFormat(simulate_transaction);
105
+ return {
106
+ status: 'success',
107
+ transaction_output: transaction_output,
108
+ };
109
+ }
110
+ catch (error) {
111
+ return {
112
+ status: 'failure',
113
+ error: error instanceof Error ? error.message : 'Unknown error',
114
+ };
115
+ }
116
+ };
117
+ //# sourceMappingURL=simulateTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulateTransaction.js","sourceRoot":"","sources":["../../src/tools/simulateTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,eAAe,EAAE,MAAM,UAAU,CAAC;AAYpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAC5C,GAAiB,EACjB,MAAuC,EACvC,EAAE;IACF,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAE5B,MAAM,WAAW,GAAwB,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACvE,OAAO;gBACL,IAAI,EAAE,eAAe,CAAC,MAAM;gBAC5B,OAAO,EAAE;oBACP,eAAe,EAAE,OAAO,CAAC,eAAe;oBACxC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,QAAQ,EAAE,OAAO,CAAC,QAAoB;iBACvC;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAA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C,OAAO;gBAC7B,OAAO,EAAE;oBACP,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;iBAC5C;aACF;SACF,CAAC;QAEF,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAC5E,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,oBAAoB,CAAC,CAAC;QAE1E,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,kBAAkB,EAAE,kBAAkB;SACvC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@kasarlabs/transaction-mcp",
3
+ "version": "0.1.0",
4
+ "main": "index.js",
5
+ "type": "module",
6
+ "bin": {
7
+ "transaction-mcp": "./bin/transaction-mcp.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc && chmod 755 build/index.js",
11
+ "clean": "rm -rf build",
12
+ "clean:all": "rm -rf build node_modules",
13
+ "start": "node build/index.js"
14
+ },
15
+ "files": [
16
+ "build"
17
+ ],
18
+ "dependencies": {
19
+ "@kasarlabs/ask-starknet-core": "0.1.0",
20
+ "@langchain/core": "^0.3.42",
21
+ "@modelcontextprotocol/sdk": "^1.11.2",
22
+ "dotenv": "^16.4.7",
23
+ "starknet": "^7.1.0",
24
+ "winston": "^3.17.0",
25
+ "zod": "^3.24.2"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^22.13.10",
29
+ "typescript": "^5.8.2"
30
+ },
31
+ "keywords": [
32
+ "mcp",
33
+ "starknet",
34
+ "transaction"
35
+ ],
36
+ "author": "kasarlabs",
37
+ "license": "MIT",
38
+ "description": "MCP server for simulating various types of transactions without execution.",
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "gitHead": "2239ec60f8e369abd318807cecd22fe97c0ab917"
43
+ }