Skip to main content
Glama

MCP SNS Server

by baolongt
wallet.ts1.58 kB
import { DelegationChain, DelegationIdentity } from "@dfinity/identity"; import { Secp256k1KeyIdentity } from "@dfinity/identity-secp256k1"; import { toBase64 } from "@slide-computer/signer"; import * as bip39 from "bip39"; import dotenv from "dotenv"; dotenv.config(); /** * Generates a random principal using BIP39 mnemonic */ function generateRandomPrincipal() { // Generate a random BIP39 mnemonic (24 words by default) const mnemonic = bip39.generateMnemonic(); // Generate a random seed from the mnemonic const seed = bip39.mnemonicToSeedSync(mnemonic).slice(0, 32); const identity = Secp256k1KeyIdentity.generate(seed); return { mnemonic, identity }; } /** * Reconstructs an identity from an existing mnemonic phrase * @param mnemonic The BIP39 mnemonic seed phrase to recover from */ function recoverFromMnemonic(mnemonic: string) { try { const seed = bip39.mnemonicToSeedSync(mnemonic).slice(0, 32); const identity = Secp256k1KeyIdentity.generate(seed); return identity; } catch (error) { console.error("Failed to recover identity from mnemonic:", error); throw error; } } export const initWallet = () => { // Get seed phrase from environment variable const seedPhrase = process.env.SEED_PHRASE; if (!seedPhrase) { throw new Error("Missing SEED_PHRASE environment variable"); } try { // Recover identity using the seed phrase const identity = recoverFromMnemonic(seedPhrase); return identity; } catch (error) { console.error("Failed to initialize wallet:", error); throw error; } };

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/baolongt/sns-mcp-server'

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