This repository is a workbench for testing several nostr implementation possibilities (NIPs). Feel free to fork and do your own things with it.
You can run the HTML files without any compiler steps. The only framework I use is AlpineJS for reactivity.
Register your relays in the relays.html
file. Read/Write will be recognized by the pool.
You can view notes in the notes.html
file.
My adblocker had an issue with the name miner.js
, so I called it PoWer.js
(Proof-of-Work (min)er). NIP-13 for more information.
I have a mining.html
file. You should have at least one relay registered in your local storage to make it work. You can use the relays.html
file to register a relay. Only kind: 0
is supported at the moment.
I use a Worker power_worker.js
to execute the heavy load of mining. It would definitely freeze your browser window.
const miner = new Worker('./power_worker.js', {type:'module'});
miner.onmessage = ev => console.log(ev.data);
miner.postMessage({
privateKey: '<YOUR_PRIVATE_KEY>',
// Must be a valid Nsotr event
event: { ... },
// Reasonable wait time: 16-21 (everything above takes time)
difficulty: 16
});
Use the client.html
to test the window.nostr
functions.
-
window.nostr.getPublicKey()
-
window.nostr.getRelays()
-
window.nostr.signEvent(event)
-
window.nostr.nip04.encrypt(pubkey, plaintext)
-
window.nostr.nip04.decrypt(pubkey, ciphertext)
-
window.nostr.nip26.createDelegation(pubkey, { kind: number, until: number, since: number })
More info on NIP-07.
The tests work if you run them one at a time. I won't fix it any time soon.