Skip to main content
Glama

export_wallet

Export your Solana wallet secret key in base58 format to import into Phantom or Solflare for direct wallet control. Rate-limited to 5 exports per hour.

Instructions

Export the agent's Solana wallet secret key in base58 format. Import into Phantom or Solflare to control the wallet directly. Rate-limited to 5 exports per hour.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idNoThe agent's profile ID. Auto-filled from saved credentials if omitted.
owner_idNoThe owner's profile ID. Auto-filled from saved credentials if omitted.
api_keyNoThe agent's API key. Alternative auth method if owner_id is not available.

Implementation Reference

  • Implementation of the export_wallet tool, which retrieves and returns the Solana wallet secret key for an agent.
    // ── Tool: export_wallet ──
    
    server.tool(
      "export_wallet",
      "Export the agent's Solana wallet secret key in base58 format. Import into Phantom or Solflare to control the wallet directly. Rate-limited to 5 exports per hour.",
      {
        agent_id: z.string().optional().describe("The agent's profile ID. Auto-filled from saved credentials if omitted."),
        owner_id: z.string().optional().describe("The owner's profile ID. Auto-filled from saved credentials if omitted."),
        api_key: z.string().optional().describe("The agent's API key. Alternative auth method if owner_id is not available."),
      },
      async ({ agent_id, owner_id, api_key }) => {
        const saved = loadSavedAgents();
        const resolvedAgent = agent_id || (saved.length > 0 ? saved[saved.length - 1].agentId : null);
        const resolvedOwner = owner_id || getDefaultOwnerId();
        const resolvedApiKey = api_key || getDefaultApiKey();
    
        if (!resolvedAgent) {
          return { content: [{ type: "text", text: "No agent found. Create one first with `create_agent`, or pass agent_id." }], isError: true };
        }
    
        if (!resolvedOwner && !resolvedApiKey) {
          return { content: [{ type: "text", text: "Auth required: provide owner_id or api_key." }], isError: true };
        }
    
        const body: Record<string, string> = { agentId: resolvedAgent };
        if (resolvedOwner) body.ownerProfileId = resolvedOwner;
        if (resolvedApiKey) body.agentApiKey = resolvedApiKey;
    
        const result = (await apiPost("export-agent-wallet", body)) as any;
    
        if (!result.success) {
          return {
            content: [{ type: "text", text: `Export failed: ${result.error || "Unknown error"}` }],
            isError: true,
          };
        }
    
        return {
          content: [
            {
              type: "text",
              text: [
                `# Wallet Export: ${result.agent?.name || resolvedAgent}`,
                "",
                `**Wallet Address:** ${result.agent?.walletAddress || "unknown"}`,
                `**Network:** ${result.wallet?.network || "solana-devnet"}`,
                `**Format:** ${result.wallet?.format || "base58"}`,
                "",
                `**Secret Key:**`,
                `\`${result.wallet?.secretKey}\``,
                "",
                `Import this into Phantom or Solflare to control the wallet.`,
                `⚠️ Anyone with this key can move funds. Keep it safe.`,
              ].join("\n"),
            },
          ],
        };
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/abcxz/conviction-fm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server