diff --git a/.vscode/settings.json b/.vscode/settings.json index 4d360cb..e75822a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,5 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "prettier.useTabs": true, + "prettier.singleQuote": false } diff --git a/helpers/bitte-client.ts b/helpers/bitte-client.ts index a0723ae..5af2276 100644 --- a/helpers/bitte-client.ts +++ b/helpers/bitte-client.ts @@ -1,6 +1,7 @@ import { createHash } from "node:crypto"; import { generateId, type ToolInvocation } from "ai"; import { + BASE_CHAIN_ID, BITTE_API_KEY, CHAT_API_URL, DEFAULT_AGENT_ID, @@ -79,7 +80,7 @@ export class BitteAPIClient { role: "system", content: systemMessage, }, - ] + ] : []), { id: messageId, @@ -100,6 +101,7 @@ export class BitteAPIClient { mcpServerUrl: MCP_SERVER_URL, }, evmAddress, + chainId: BASE_CHAIN_ID, }; try { diff --git a/helpers/config.ts b/helpers/config.ts index 8e6bb3e..d6f677d 100644 --- a/helpers/config.ts +++ b/helpers/config.ts @@ -2,6 +2,8 @@ import dotenv from "dotenv"; dotenv.config(); +export const BASE_CHAIN_ID = 8453; + // Configuration export const { WALLET_KEY, @@ -57,7 +59,7 @@ export const { mainnet: { chainId: 1, rpcUrl: "https://eth.llamarpc.com" }, polygon: { chainId: 137, rpcUrl: "https://polygon.llamarpc.com" }, arbitrum: { chainId: 42161, rpcUrl: "https://arbitrum.llamarpc.com" }, - base: { chainId: 8453, rpcUrl: "https://base.llamarpc.com" }, + base: { chainId: BASE_CHAIN_ID, rpcUrl: "https://base.llamarpc.com" }, }, NEAR: { mainnet: { diff --git a/helpers/tools.ts b/helpers/tools.ts index 4293ebd..f44dce5 100644 --- a/helpers/tools.ts +++ b/helpers/tools.ts @@ -1,5 +1,6 @@ import type { ToolInvocation } from "ai"; import { parseEther, toHex } from "viem/utils"; +import { BASE_CHAIN_ID } from "./config"; export const extractEvmTxCall = ( toolCall: ToolInvocation, @@ -7,7 +8,7 @@ export const extractEvmTxCall = ( ) => { const params = toolCall?.args?.params || []; const chainId = toolCall?.args?.chainId; - const chainIdHex = toHex(Number.parseInt(chainId || "8453")); + const chainIdHex = toHex(chainId ? Number.parseInt(chainId) : BASE_CHAIN_ID); const method = toolCall?.args?.method; // Extract all calls from the params array diff --git a/server.ts b/server.ts index 6637af0..a06ba4f 100644 --- a/server.ts +++ b/server.ts @@ -25,6 +25,7 @@ import { } from "@/helpers/client"; import { AGENT_CHAT_ID, + BASE_CHAIN_ID, ENCRYPTION_KEY, IS_PRODUCTION, WALLET_KEY, @@ -171,11 +172,11 @@ async function main() { - If asked, you are built by the bitte.ai team and running on Bitte Protocol, don't mention OpenAI or any other LLM - Example: 'This is an experimental tool built by the team at Bitte.ai, a group of builders focused on making crypto accessible through AI.' -- Recommend simple actions/swaps like ETH -> USDC for users experimenting +- Recommend simple actions/swaps like ETH -> USDC for users experimenting Example: 'I help you manage your portfolio through natural language — like buy, sell, swap, or what's going on with the market.' - -- Assume the user is interacting on Base chainId (8453) unless explicitly requested to use a different chain. + +- Assume the user is interacting on Base chainId (${BASE_CHAIN_ID}) unless explicitly requested to use a different chain. `, message: messageString, evmAddress: addressFromInboxId, @@ -209,7 +210,7 @@ Example: const result = swapResult.result; const txData = result.data?.transaction; if (txData?.params) { - const chainId = toHex(txData.chainId || 8453); + const chainId = toHex(txData.chainId || BASE_CHAIN_ID); // Generate swap description from token parameters const sellToken = swapCall.args?.sellToken || "Token A";