Steem-Tx | Now on Browsers + benchmark

Words
161
Reading
1 min
Listen
Play
7y

steem-tx.jpg

Steem-Tx is a lightweight and complete JavaScript library for using Steem blockchain in Javascript environments such as Web or NodeJS.

Two months ago Steem-tx has been announced. At that time, using it only was possible in the NodeJS applications (and not Websites).

With the help of browserify and tinyify now it's possible to use Steem-tx on the browser too.

Thanks to JSDeliver, minified Javascript file is available on the CDN and also on the GitHub repository:
https://cdn.jsdelivr.net/npm/steem-tx/dist/steem-tx.min.js

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

Everything works like NodeJS apps.
A full example of Web usage which you can copy and run in your browser too:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <script src="https://cdn.jsdelivr.net/npm/steem-tx/dist/steem-tx.min.js"></script>
    <title>Test steem-tx</title>
  </head>
  <body>
    <script>
      // change api
      steemTx.config.node = 'https://anyx.io'

      const operations = [
        [
          'vote',
          {
            voter: 'guest123',
            author: 'guest123',
            permlink: '20191107t125713486z-post',
            weight: 9900
          }
        ]
      ]
      const myKey = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'
      const privateKey = steemTx.PrivateKey.from(myKey)

      const tx = new steemTx.Transaction()

      // create transaction
      tx.create(operations).then(() => {
        console.log('Created transaction:', tx.transaction)

        // sign the transaction
        tx.sign(privateKey)
        console.log('Signed transaction:', tx.signedTransaction)

        // broadcast the transaction
        tx.broadcast().then(res => console.log('Broadcast result:', res))
      })

      // get accounts
      steemTx
        .call('condenser_api.get_accounts', [['mahdiyari']])
        .then(res => console.log('Get accounts:', res))
    </script>
  </body>
</html>

This example is also available in the GitHub repository


Benchmark

I don't know how precise measurethat.net is, but here is the benchmark link.
I believe results should be bigger than 1,000 ops/sec for both dsteem and steem-tx. (maybe I'm wrong)

alt

Also, on the NodeJS:

alt


GitHub repository: https://github.com/mahdiyari/steem-tx-js
NPM package: https://www.npmjs.com/package/steem-tx

Feel free to test, use, and share. With the hope for better Steem!

Steem-Tx | Now on Browsers + benchmark | Ecency