Skip to content

mstoecklein/nostr-experiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nostr-experiments

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.

Relays

Register your relays in the relays.html file. Read/Write will be recognized by the pool.

Notes (note, naddr, nevent)

You can view notes in the notes.html file.

Proof-of-Work (Mining)

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.

Mining Workflow

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
});

NIP-07 Capability for Web Browsers

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.

Tests

The tests work if you run them one at a time. I won't fix it any time soon.

About

Experimenting with Nostr Protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published