Skip to content

Instantly share code, notes, and snippets.

@SamSamskies
Last active September 22, 2024 15:46
Show Gist options
  • Save SamSamskies/0088e7a14f3df37550c796481b54d0fe to your computer and use it in GitHub Desktop.
Save SamSamskies/0088e7a14f3df37550c796481b54d0fe to your computer and use it in GitHub Desktop.

Revisions

  1. SamSamskies revised this gist Sep 22, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion thepoofening.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ const pool = new SimplePool()
    const relays = ['wss://nostr.mutinywallet.com']

    const events = await pool.list(relays, [{
    kinds: [30023],
    kinds: [1, 6, 30023],
    authors: ['604e96e099936a104883958b040b47672e0f048c98ac793f37ffe4c720279eb2'],
    limit: 256
    }])
  2. SamSamskies created this gist Sep 22, 2024.
    32 changes: 32 additions & 0 deletions thepoofening.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    import 'websocket-polyfill'
    import {SimplePool, finishEvent, nip19} from 'nostr-tools'
    import 'dotenv/config'

    const privateKey = nip19.decode(process.env.NOSTR_NSEC).data;

    const pool = new SimplePool()
    const relays = ['wss://nostr.mutinywallet.com']

    const events = await pool.list(relays, [{
    kinds: [30023],
    authors: ['604e96e099936a104883958b040b47672e0f048c98ac793f37ffe4c720279eb2'],
    limit: 256
    }])
    const tags = events.map(({id}) => ["e", id])

    const event = {
    kind: 5,
    created_at: Math.floor(Date.now() / 1000),
    tags,
    content: '#thepoofening',
    }
    const signedEvent = finishEvent(event, privateKey)

    const pubs = pool.publish(relays, signedEvent)
    await Promise.all(pubs)

    console.log(JSON.stringify(signedEvent, null, 2))
    console.log(events.length)


    process.exit(0)