Why Nostr? What is Njump?
2024-07-01 01:28:35

liminal 🦠 on Nostr: PABLOF7z JeffG I'm clearly missing something simple here. Can't find any example that ...


I'm clearly missing something simple here. Can't find any example that uses NDKPrivateKeySigner either.

```
import NDK, {
NDKEvent,
NDKFilter,
NDKPrivateKeySigner,
} from "@nostr-dev-kit/ndk";

const signer = NDKPrivateKeySigner.generate();
console.log(signer);

const ndk = new NDK({
explicitRelayUrls: ["wss://relay.damus.io", "wss://relay.nostr.band"],
signer: signer,
});
const ndkEvent = new NDKEvent(ndk);
ndkEvent.kind = 1;
ndkEvent.content = "Hello, world!";
ndkEvent.created_at = Math.floor(Date.now() / 1000);
ndk.connect().then(() => {
ndkEvent.publish().then(() => {
console.log("Event published!");
});
});
```

```
file:///home/user/Documents/Programming/upload_files/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nostr-dev-kit/ndk/dist/index.mjs:670
this.sig = await _signer.sign(nostrEvent);
^

TypeError: Cannot read properties of undefined (reading 'sign')
at NDKEvent.sign (file:///home/user/Documents/Programming/upload_files/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nostr-dev-kit/ndk/dist/index.mjs:670:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async NDKEvent.publish (file:///home/user/Documents/Programming/upload_files/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nostr-dev-kit/ndk/dist/index.mjs:679:7)
```
Author Public Key
npub1m3xdppkd0njmrqe2ma8a6ys39zvgp5k8u22mev8xsnqp4nh80srqhqa5sf