0.0.28 • Published 6 months ago

@pulsechain/msgboard v0.0.28

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
6 months ago

@pulsechain/msgboard

distribute messages across networks using Proof of Work as the gate.

setup

npm i --save @pulsechain/msgboard

usage

using viem

import * as msgboard from '@pulsechain/msgboard'
import { createPublicClient, http } from 'viem'
import { pulsechainV4 } from 'viem/chains'
// create a public client for connecting to a node
const client = createPublicClient({
  transport: http(),
  chain: pulsechainV4,
})
// create the msgboard client
const board = new msgboard.MsgBoardClient(msgboard.wrap1193(client))
// do the work for your given category and data
const work = await board.doPoW('category', 'data')
// send valid work to the network
const hash = board.addMessage(work)

using ethers

import * as msgboard from '@pulsechain/msgboard'
import { providers } from 'ethers'
import { pulsechainV4 } from 'viem/chains'
// create a public client for connecting to a node
const client = new providers.JsonRpcProvider('https://my-msgboard-rpc.io')
// create the msgboard client
const board = new msgboard.MsgBoardClient(client)
// do the work for your given category and data
const work = await board.doPoW('category', 'data')
// send valid work to the network
const hash = board.addMessage(work)

understanding difficulty

difficulty can be computed by passing an encoded hex string to the getDifficulty method

board.getDifficulty('0x') // 167_772n

or by looking at the the difficulty utility found in @pulsechain/msgboard/utils

((2n ** 24n + BigInt(dataLen) * 10_000n) * workMultiplier) / workDivisor

The length of data is measured using bytes instead of hex characters. Each byte adds 10_000 increase in difficulty with the default settings. This is anticipated to encourage efficient message packing strategies while not completely out running the difficulty needed to send on the network.

blocking

because javascript blocks during proof of work checks, putting the work under a process separate from your UI render is worth consideration.

future features

  • update block by event rather than timeout
0.0.28

6 months ago

0.0.26

6 months ago

0.0.25

7 months ago

0.0.24

12 months ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago