Skip to content

Instantly share code, notes, and snippets.

View Realman78's full-sized avatar
🌏
Focusing

Marin Dedić Realman78

🌏
Focusing
View GitHub Profile
@Realman78
Realman78 / PeerIdManager.ts
Last active November 12, 2025 05:23
Libp2p with static peer IDs
import { readFile, writeFile } from 'fs/promises'
import { existsSync } from 'fs'
import { generateKeyPair, privateKeyToProtobuf, privateKeyFromProtobuf } from '@libp2p/crypto/keys'
import { peerIdFromPrivateKey } from '@libp2p/peer-id'
import type { PrivateKey } from '@libp2p/interface'
import type { PeerId } from '@libp2p/interface'
/**
* Utility class for managing persistent libp2p peer IDs
*