helius_get_program_accounts
Retrieve all accounts owned by a specific program on the Solana blockchain to analyze program data and interactions.
Instructions
Get all accounts owned by a program
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| programId | Yes | ||
| commitment | No |
Implementation Reference
- src/handlers/helius.ts:193-205 (handler)The handler function that executes the tool logic: validates the programId public key, fetches program accounts using Helius RPC connection.getProgramAccounts, and returns a success or error response.export const getProgramAccountsHandler = async (input: GetProgramAccountsInput): Promise<ToolResultSchema> => { const programIdResult = validatePublicKey(input.programId); if (!(programIdResult instanceof PublicKey)) { return programIdResult; } try { const programAccounts = await (helius as any as Helius).connection.getProgramAccounts(programIdResult, input.commitment); return createSuccessResponse(`Program accounts: ${JSON.stringify(programAccounts, null, 2)}`); } catch (error) { return createErrorResponse(`Error getting program accounts: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools.ts:150-161 (schema)The tool schema definition in the tools array, including name, description, and inputSchema for programId (required) and optional commitment level.{ name: "helius_get_program_accounts", description: "Get all accounts owned by a program", inputSchema: { type: "object", properties: { programId: { type: "string" }, commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] } }, required: ["programId"] } },
- src/tools.ts:561-561 (registration)The registration of the tool name to its handler function in the handlers dictionary."helius_get_program_accounts": getProgramAccountsHandler,