@@ -36,7 +36,7 @@ import type { SupportedChain } from '../types';
3636
3737export class WalletProvider {
3838 private cacheKey = 'evm/wallet' ;
39- chains : Record < string , Chain > = { ... viemChains } ;
39+ chains : Record < string , Chain > = { } ;
4040 account ! : PrivateKeyAccount ;
4141 runtime : IAgentRuntime ;
4242 constructor (
@@ -45,7 +45,9 @@ export class WalletProvider {
4545 chains ?: Record < string , Chain >
4646 ) {
4747 this . setAccount ( accountOrPrivateKey ) ;
48- this . addChains ( chains ) ;
48+ if ( chains ) {
49+ this . chains = chains ;
50+ }
4951 this . runtime = runtime ;
5052 }
5153
@@ -159,9 +161,8 @@ export class WalletProvider {
159161 if ( ! chains ) {
160162 return ;
161163 }
162- for ( const chain of Object . keys ( chains ) ) {
163- this . chains [ chain ] = chains [ chain ] ;
164- }
164+ // Only add the chains that are explicitly provided
165+ this . chains = { ...this . chains , ...chains } ;
165166 } ;
166167
167168 private createHttpTransport = ( chainName : SupportedChain ) => {
@@ -200,17 +201,19 @@ export class WalletProvider {
200201}
201202
202203const genChainsFromRuntime = ( runtime : IAgentRuntime ) : Record < string , Chain > => {
203- // Get chains from settings or use default supported chains
204+ // Get chains from settings - ONLY use configured chains
204205 const configuredChains = ( runtime ?. character ?. settings ?. chains ?. evm as SupportedChain [ ] ) || [ ] ;
205206
206- // Default chains to include if not specified in settings
207- const defaultChains = [ 'mainnet' , 'polygon' , 'arbitrum' , 'base' , 'optimism' , 'linea' ] ;
207+ // If no chains are configured, default to mainnet and base
208+ const chainsToUse = configuredChains . length > 0 ? configuredChains : [ 'mainnet' , 'base' ] ;
209+
210+ if ( ! configuredChains . length ) {
211+ elizaLogger . warn ( 'No EVM chains configured in settings, defaulting to mainnet and base' ) ;
212+ }
208213
209- // Combine configured chains with defaults, removing duplicates
210- const chainNames = [ ...new Set ( [ ...configuredChains , ...defaultChains ] ) ] ;
211214 const chains : Record < string , Chain > = { } ;
212215
213- for ( const chainName of chainNames ) {
216+ for ( const chainName of chainsToUse ) {
214217 try {
215218 // Try to get RPC URL from settings using different formats
216219 let rpcUrl = runtime . getSetting ( `ETHEREUM_PROVIDER_${ chainName . toUpperCase ( ) } ` ) ;
@@ -227,6 +230,7 @@ const genChainsFromRuntime = (runtime: IAgentRuntime): Record<string, Chain> =>
227230
228231 const chain = WalletProvider . genChainFromName ( chainName , rpcUrl ) ;
229232 chains [ chainName ] = chain ;
233+ elizaLogger . log ( `Configured chain: ${ chainName } ` ) ;
230234 } catch ( error ) {
231235 elizaLogger . error ( `Error configuring chain ${ chainName } :` , error ) ;
232236 }
0 commit comments