hive-tx v7
GitHub npm

Use

Utilities

The utils object validates names, builds history filters, and builds witness properties.

validateUsername

The function returns null if the name is valid. The function returns an error string if the name is not valid.

import { utils } from 'hive-tx'

const error = utils.validateUsername('alice')
if (error) {
  console.log(error)
}

makeBitMaskFilter

Use the filter with condenser_api.get_account_history.

const filter = utils.makeBitMaskFilter([
  utils.operations.transfer,
  utils.operations.vote,
  utils.operations.comment
])
const history = await callRPC('condenser_api.get_account_history', [
  'alice',
  -1,
  100,
  ...filter
])

utils.operations maps operation names to numeric ids. Example: vote is 0. transfer is 2.

buildWitnessSetProperties

This helper is required for witness_set_properties. The helper serializes property values to hex.

const operation = utils.buildWitnessSetProperties('mywitness', {
  key: 'STM1111111111111111111111111111111114T1Anm',
  account_creation_fee: '0.000 HIVE',
  maximum_block_size: 65536,
  url: 'https://example.com'
})
const tx = new Transaction()
await tx.addOperation(operation[0], operation[1])

The key field is required. The field is the current signing public key.