Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"prettier.useTabs": true,
"prettier.singleQuote": false
}
4 changes: 3 additions & 1 deletion helpers/bitte-client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -79,7 +80,7 @@ export class BitteAPIClient {
role: "system",
content: systemMessage,
},
]
]
: []),
{
id: messageId,
Expand All @@ -100,6 +101,7 @@ export class BitteAPIClient {
mcpServerUrl: MCP_SERVER_URL,
},
evmAddress,
chainId: BASE_CHAIN_ID,
};

try {
Expand Down
4 changes: 3 additions & 1 deletion helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import dotenv from "dotenv";

dotenv.config();

export const BASE_CHAIN_ID = 8453;

// Configuration
export const {
WALLET_KEY,
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion helpers/tools.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { ToolInvocation } from "ai";
import { parseEther, toHex } from "viem/utils";
import { BASE_CHAIN_ID } from "./config";

export const extractEvmTxCall = (
toolCall: ToolInvocation,
addressFromInboxId: string,
) => {
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
Expand Down
9 changes: 5 additions & 4 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from "@/helpers/client";
import {
AGENT_CHAT_ID,
BASE_CHAIN_ID,
ENCRYPTION_KEY,
IS_PRODUCTION,
WALLET_KEY,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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";
Expand Down