@pulsechain/msgboard v0.0.28
@pulsechain/msgboard
distribute messages across networks using Proof of Work as the gate.
setup
npm i --save @pulsechain/msgboardusage
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_772nor by looking at the the difficulty utility found in @pulsechain/msgboard/utils
((2n ** 24n + BigInt(dataLen) * 10_000n) * workMultiplier) / workDivisorThe 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
6 months ago
6 months ago
7 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago