Skip to content

Instantly share code, notes, and snippets.

@nikolat
Created February 13, 2023 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikolat/08e1bb1fc99b5637772a11538490b924 to your computer and use it in GitHub Desktop.
Save nikolat/08e1bb1fc99b5637772a11538490b924 to your computer and use it in GitHub Desktop.
practice of nostr-tools
// nostr-tools
// https://github.com/nbd-wtf/nostr-tools
// Nostr-basedなソフトウェアを書く際のコツ
// https://txt.murakmii.dev/posts/nostr-based-software-practice
// Nostrプロトコル(damus)を触ってみた
// https://qiita.com/gpsnmeajp/items/77eee9535fb1a092e286
// CC0-1.0 license
import {Filter, SimplePool} from 'nostr-tools';
import 'websocket-polyfill';
function main() {
const pool = new SimplePool();
let relays = [
'wss://relay-jp.nostr.wirednet.jp',
'wss://nostr-relay.nokotaro.com',
'wss://relay.nostr.wirednet.jp',
'wss://nostr.h3y6e.com'
];
let f: Filter = {
kinds: [1],
since: Math.floor(Date.now() / 1000)
};
let subs = pool.sub(relays, [f]);
subs.on('event', (event: any) => {
console.log(event);
});
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment