JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q39321F
  • License MIT

Create, sign, and broadcast transactions on Blurt blockchain

Package Exports

  • blurt-tx

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (blurt-tx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hive-tx-js

Lightweight and complete JavaScript library for using Hive blockchain in Javascript environments such as Web or NodeJS.

Why this?

Most lightweight library to use in your applications.

Some libraries are not easy to integrate and in some cases are incompatible with some frameworks like Nativescript

This library is a solution to such cases when official libraries are not working. And also an lightweight alternative for other libraries.

Installation

npm install hive-tx --save

Usage

Browser:

<script src="https://cdn.jsdelivr.net/npm/hive-tx/dist/hive-tx.min.js"></script>

or

<script src="dist/hive-tx.min.js"></script>

hiveTx is available after including /dist/hive-tx.min.js file in your html file.

NodeJS:

const hiveTx = require('hive-tx')

Usage examples

Configuration

Set or get configs:

// default values already defined in config.js
hiveTx.config.node = "https://api.hive.blog"
hiveTx.config.chain_id = "beeab0de00000000000000000000000000000000000000000000000000000000"
hiveTx.config.address_prefix = "STM"

Create transaction:

const tx = new hiveTx.Transaction(trx?)

or

const tx = new hiveTx.Transaction()
tx.create(operations, expiration = 60)

Example:

const operations = [
  [
    'vote',
    {
      voter: 'guest123',
      author: 'guest123',
      permlink: '20191107t125713486z-post',
      weight: 9900
    }
  ]
]

const tx = new hiveTx.Transaction()
tx.create(operations).then(() => console.log(tx.transaction))

Sign transaction:

const myKey = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'
const privateKey = hiveTx.PrivateKey.from(myKey)

tx.sign(privateKey)
console.log(tx.signedTransaction)

Broadcast transaction:

tx.broadcast().then(res => console.log(res))

Make node call:

hiveTx.call(method, params = [], timeout = 10): Promise

Example:

hiveTx.call('condenser_api.get_accounts', [['mahdiyari']]).then(res => console.log(res))

License

MIT

Note: In building some parts we used functions from dsteem library