How to Set Up the SDK in Node.js Environments
Start with the right set up of your environments!
Solana Network Configuration for Application Setup
This document describes the initial setup process for configuring network settings in a Solana-based application. Following these guidelines ensures that your application environment is prepared correctly with the necessary configurations.
By default, configuration constants include pre-set values. However, you can customize these defaults using the createDefaultConfig
method from ConfigManager class. This function allows you to tailor the configuration by providing specific values for privateKey
, openAiKey
, and optionally solanaEndpoint
, solanaUnofficialEndpoints
, and solanaExplorer
. It returns an IConfiguration
object with your specified values or the default ones if none are provided.
The ConfigManager
class is a core utility in the OOBE Protocol that handles configuration management for Solana network connections, agent credentials, and other system parameters. It provides a centralized and flexible way to:
Manage official and unofficial Solana RPC endpoints.
Handle sensitive data like private keys, API keys, and Merkle tree seeds.
Dynamically create or update configurations at runtime for different agents or tools.
Provide a stable and extendable config interface for the OOBE system and its tools.
Imported Types
import { IConfiguration, IOfficialEndpoint, ISolanaEndpoint, IUnofficialEndpoints } from "./types/config.types";
These interfaces define the structure and types for Solana endpoints and agent configuration. They help enforce type safety and consistency across the system. Key Properties
A default official Solana RPC endpoint.
A list of unofficial fallback endpoints from reliable providers (e.g., GenesysGo, Project Serum, Triton), useful for load balancing or avoiding rate limits. [deperecated] - use transportsRPC
Includes:
Solana RPC settings.
API and private keys (
openAiKey
,oobeKey [use empty string]
,private_key
).Merkle tree seeds (
merkleDbSeed
,merkleRootSeed
).A list of alternative RPC transports used to ensure request reliability (
transportsRPC
).
import { IConfiguration, IOfficialEndpoint, ISolanaEndpoint, IUnofficialEndpoints } from "./types/config.types";
export class ConfigManager {
private endpointsConfig: ISolanaEndpoint;
private defaultConfig: IConfiguration;
constructor() {
this.endpointsConfig = {
official: {
rpc: "https://api.mainnet-beta.solana.com"
},
unOfficial: [
{
name: "GenesysGo",
rpc: "https://ssc-dao.genesysgo.net",
},
{
name: "Project Serum",
rpc: "https://solana-api.projectserum.com",
},
{
name: "Triton",
rpc: "https://rpc.triton.one",
}
]
};
this.defaultConfig = {
solanaEndpoint: this.endpointsConfig.official as IOfficialEndpoint,
solanaUnofficialEndpoints: this.endpointsConfig.unOfficial as IUnofficialEndpoints[],
solanaExplorer: "https://explorer.solana.com",
private_key: "",
openAiKey: "",
oobeKey: "",
merkleDbSeed: "oobedbleaf!",
merkleRootSeed: "oobedbroot!",
strategy_key: '',
transportsRPC: [
'https://api.mainnet-beta.solana.com', // Solana Labs (Ufficiale)
'https://rpc.shdw.genesysgo.net', // GenesysGo (Shadow RPC)
'https://solana-rpc.publicnode.com', // PublicNode
'https://solana.drpc.org', // dRPC
'https://endpoints.omniatech.io/v1/sol/mainnet/public', // OMNIA
'https://solana.api.onfinality.io/public', // OnFinality
],
};
}
public createEndpointsConfig(officialRpc?: string, unofficialEndpoints?: { name: string, rpc: string }[]): ISolanaEndpoint {
return {
official: {
rpc: officialRpc || this.endpointsConfig.official.rpc
},
unOfficial: unofficialEndpoints || this.endpointsConfig.unOfficial
} as ISolanaEndpoint;
}
public createDefaultConfig(
privateKey: string,
openAiKey: string,
oobeKey: string,
solanaEndpoint?: IOfficialEndpoint,
solanaUnofficialEndpoints?: IUnofficialEndpoints[],
solanaExplorer?: string,
merkleDbSeed: string = "oobedbleaf!",
merkleRootSeed: string = "oobedbroot!",
strategy_key?: string,
transportsRPC?: string[],
): IConfiguration {
return {
solanaEndpoint: solanaEndpoint || this.endpointsConfig.official,
solanaUnofficialEndpoints: solanaUnofficialEndpoints ?? this.endpointsConfig.unOfficial ?? [],
solanaExplorer: solanaExplorer ?? this.defaultConfig.solanaExplorer ?? "",
private_key: privateKey,
openAiKey: openAiKey,
oobeKey: oobeKey,
merkleDbSeed: merkleDbSeed,
merkleRootSeed: merkleRootSeed,
strategy_key: strategy_key || '',
transportsRPC: transportsRPC || [],
};
}
public getDefaultConfig(): IConfiguration {
return this.defaultConfig;
}
public setDefaultConfig(config: IConfiguration | Partial<IConfiguration>): IConfiguration {
this.defaultConfig = { ...this.defaultConfig, ...config };
return this.defaultConfig;
}
}
⚙️ Core Methods
createEndpointsConfig(...)
public createEndpointsConfig(officialRpc?, unofficialEndpoints?): ISolanaEndpoint
Dynamically creates a new RPC configuration object. Useful when deploying agents with custom RPCs.
createDefaultConfig(...)
public createDefaultConfig(privateKey, openAiKey, oobeKey, ...)
Creates a full IConfiguration
object based on runtime values or default fallbacks. Ideal for spawning new agents or tools with different settings.
getDefaultConfig()
Returns the current default configuration, typically used by the agent core or a Tool during initialization.
setDefaultConfig(...)
public setDefaultConfig(config: IConfiguration | Partial<IConfiguration>)
Updates the internal configuration with new or partial values. Enables runtime flexibility and modular state management.
After setting up and exporting the configurations, these settings are funneled into the OobeCore
class. This class undertakes the essential task of laying down the environment for the application, ensuring all components interact seamlessly and securely. It prepares the application framework, leveraging the defined configurations to maintain robust operations across the Solana network.
By adhering to the steps outlined in this document, you assure a comprehensive and secure setup of your Solana-based application's network environment, positioning it for optimal performance and reliability.
Last updated