Created
February 13, 2023 11:42
-
-
Save nikolat/08e1bb1fc99b5637772a11538490b924 to your computer and use it in GitHub Desktop.
practice of nostr-tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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