Skip to content
Merged
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
18 changes: 11 additions & 7 deletions typescript/examples/langchain-privy-chatbot/chatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ function validateEnvironment(): void {
});
process.exit(1);
}

// Warn about optional CHAIN_ID
if (!process.env.CHAIN_ID) {
console.warn("Warning: CHAIN_ID not set, defaulting to base-sepolia testnet");
}
}

// Add this right after imports and before any other code
Expand Down Expand Up @@ -99,7 +94,7 @@ async function initializeAgent() {
const config: PrivyWalletConfig = {
appId: process.env.PRIVY_APP_ID as string,
appSecret: process.env.PRIVY_APP_SECRET as string,
chainId: process.env.CHAIN_ID || "84532",
chainId: process.env.CHAIN_ID,
walletId: process.env.PRIVY_WALLET_ID as string,
authorizationPrivateKey: process.env.PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY,
authorizationKeyId: process.env.PRIVY_WALLET_AUTHORIZATION_KEY_ID,
Expand All @@ -111,7 +106,16 @@ async function initializeAgent() {
const savedWallet = JSON.parse(fs.readFileSync(WALLET_DATA_FILE, "utf8"));
config.walletId = savedWallet.walletId;
config.authorizationPrivateKey = savedWallet.authorizationPrivateKey;
config.chainId = savedWallet.chainId;

if (savedWallet.chainId) {
console.log("Found chainId in wallet_data.txt:", savedWallet.chainId);
config.chainId = savedWallet.chainId;
}
}

if (!config.chainId) {
console.log("Warning: CHAIN_ID not set, defaulting to 84532 (base-sepolia)");
config.chainId = "84532";
}

walletProvider = await PrivyWalletProvider.configureWithWallet(config);
Expand Down
Loading