Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 716 Bytes

readme.md

File metadata and controls

35 lines (27 loc) · 716 Bytes

lotion-haiku

collaborative haiku-writing app on a blockchain. built on Lotion.

npm install -g lotion-haiku

# to join an existing chat:
haiku -j <chat id> -p <initial peers>

look how simple the blockchain logic is:

let syllables = require('syllables')

let haikuHandler = (state, tx) => {
  if (
    typeof tx.sender === 'string' &&
    typeof tx.message === 'string' &&
    tx.message.length <= 50
  ) {
    let requiredSyllables = state.messages.length % 3 === 1 ? 7 : 5
    if (syllables(tx.message) === requiredSyllables) {
      state.messages.push({
        sender: tx.sender,
        message: tx.message
      })
    }
  }
}

lotion(haikuHandler)