-
@ ever4st
2025-02-21 20:38:43``` python
!/usr/bin/env python3
import asyncio from nostr_sdk import Metadata, Client, NostrSigner, Keys, Filter, PublicKey, Kind, init_logger, LogLevel from datetime import timedelta
async def main(): init_logger(LogLevel.INFO) secret_key = "nsec1........Replace with your actual nsec secret key" keys = Keys.parse(secret_key) signer = NostrSigner.keys(keys) client = Client(signer)
await client.add_relay("wss://relay.damus.io") await client.connect() # Update metadata new_metadata = Metadata().set_name( "MyName")\ .set_nip05("MyName@example.com")\ .set_lud16("MyName@lud16.com") await client.set_metadata(new_metadata) print("Metadata updated successfully.") # Get updated metadata npub = "npub1....Replace with your actual npub" pk = PublicKey.parse(npub) print(f"\nGetting profile metadata for {npub}:") metadata = await client.fetch_metadata(pk, timedelta(seconds=15)) print(metadata)
if name == 'main': asyncio.run(main()) ```