BTSDEX v0.6.0

in #utopian-io6 years ago

BTSDEX.png

<p dir="auto">Here comes the new version of the <code>btsdex package. At first I planned to release the package by increasing the last number (patch), but due to the loss of compatibility, I had to increase the minor number. I hope you will like the changes. <h2>Loss of compatibility <p dir="auto">In all previous versions, before using the <code>BitShares class, it was necessary to initialize it: <pre><code>BitShares.init(<node>, <autoconnect>, <autoreconnect>) <p dir="auto">Now this method is not. But the <code>connect method has been enriched with parameters: <pre><code>BitShares.connect(<node>, <autoreconnect>) <p dir="auto">If you use an event system to connection, and you want to specify connection parameters, use <code>BitShares.node and<code>BitShares.autoreconnect to do this. <pre><code>const BitShares = require("btsdex"); BitShares.node = "wss://api.bts.blckchnd.com"; BitShares.autoreconnect = false;// default true BitShares.subscribe("connected", start); async function start() { // code here } <p dir="auto">This is the only incompatibility with other versions. <h2>Transaction builder <p dir="auto">Each transaction is considered accepted after inclusion in the block. Blocks are created every 3 seconds. If you need to perform several operations, their sequential execution can take considerable time. Fortunately, several operations can be included in a single transaction. To do this, use the transaction builder. <p dir="auto">To create a new transaction: <pre><code>let tx = BitShares.newTx([<activePrivateKey>, ...]) <p dir="auto">or if you already have an instance of the <code>BitShares class: <pre><code>let acc = await BitShares.login(<accountName>, <password>); let tx = acc.newTx() <p dir="auto">Each operation available out of the box has a method (<code><name>Operation) that forms the operation object, but does not send it to the blockchain. <p dir="auto">To obtain the objects of operations: <pre><code>let operation1 = await acc.transferOperation("scientistnik", "BTS", 10) let operation2 = await acc.assetIssueOperation("scientistnik", "ABC", 10) ... <p dir="auto">Adding operations to a transaction: <pre><code>tx.add(operation1) tx.add(operation2) ... <p dir="auto">You can get the cost of the transaction: <pre><code>let cost = await tx.cost() console.log(cost) // {BTS: 1.234} <p dir="auto">After that, the transaction can be sent: <pre><code>await tx.broadcast() <p dir="auto">or <pre><code>await acc.broadcast(tx) <p dir="auto">The operations available to the account in the BitShares network are much more than the available object of the class <code>BitShares. If you know which fields are necessary for an operation, you can use the transaction builder to submit this operation. <p dir="auto">Example of creating a new account: <pre><code>let BitShares = require("btsdex") BitShares.subscribe("connected", start) async function start () { let acc = await BitShares.login(<accountName>, <password>) let params = { fee: {amount: 0, asset_id: "1.3.0"}, name: "trade-bot3", registrar: "1.2.21058", referrer: "1.2.21058", referrer_percent: 5000, owner: { weight_threshold: 1, account_auths: [], key_auths: [[<ownerPublicKey>, 1]], address_auths: [] }, active: { weight_threshold: 1, account_auths: [], key_auths: [[<activePublicKey>, 1]], address_auths: [] }, options: { memo_key: <memoPublicKey>, voting_account: "1.2.5", num_witness: 0, num_committee: 0, votes: [] }, extensions: [] }; let tx = acc.newTx() tx.account_create(params) // 'account_create' is the name of the operation await tx.broadcast() } <h2>One-time request in REPL mode <p dir="auto">If you only need to make one request, you can use <code>--account,<code>--asset, <code>--block,<code>--object, <code>--history,<code>--node or <code>--transfer command line keys: <pre><code>$ btsdex --account <'name' or 'id' or 'last number in id'> { "id": "1.2.5992", "membership_expiration_date": "1970-01-01T00: 00: 00", "registrar": "1.2.37", "referrer": "1.2.21", ... } $ btsdex --asset <'symbol' or 'id' or 'last number in id'> { "id": "1.3.0", "symbol": "BTS", "precision": 5, ... } $ btsdex --block [<number>] block_num: 4636380 { "previous": "0046bedba1317d146dd6afbccff94412d76bf094", "timestamp": "2018-10-01T13: 09: 40", "witness": "1.6.41", ... } $ btsdex --object 1.2.3 { "id": "1.2.3", "membership_expiration_date": "1969-12-31T23: 59: 59", "registrar": "1.2.3", "referrer": "1.2.3", ... } $ btsdex --history <account> [<limit>] [<start>] [<stop>] [ { "id": "1.11.98179", "op": [ 0, ... }] $ btsdex --node wss: //api.bts.blckchnd.com Connected to API node: wss: //api.bts.blckchnd.com $ btsdex --transfer <from> <to> <amount> <asset> [--key] Transfered <amount> <asset> from '<from>' to '<to>' with memo '<memo>' <h2>Documentation Update <p dir="auto">Updated <a href="https://scientistnik.github.io/btsdex/#/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">documentation, added its <a href="https://scientistnik.github.io/btsdex/#/ru/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Russian version. <hr /> <p dir="auto">If you have any wishes for further development of the package, or perhaps there is no very useful function, write on GitHub, or if you want to talk in person, use Telegram-channel <a href="https://t.me/btsdex" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">btsdex. <p dir="auto">I have it all. Great weekend to everyone!
Sort:  

Congratulations @scientistnik! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><span><img src="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@scientistnik/voted.png?201810282336" srcset="https://images.hive.blog/768x0/https://steemitimages.com/60x70/http://steemitboard.com/@scientistnik/voted.png?201810282336 1x, https://images.hive.blog/1536x0/https://steemitimages.com/60x70/http://steemitboard.com/@scientistnik/voted.png?201810282336 2x" /><td>You received more than 250 upvotes. Your next target is to reach 500 upvotes. <p dir="auto"><sub><em><a href="https://steemitboard.com/@scientistnik" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Click here to view your Board of Honor<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong><span>Do not miss the last post from <a href="/@steemitboard">@steemitboard: <table><tr><td><a href="https://steemit.com/halloween/@steemitboard/trick-or-treat-publish-your-scariest-halloweeen-story-and-win-a-new-badge" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/RUyB3u.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/RUyB3u.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/64x128/http://i.cubeupload.com/RUyB3u.png 2x" /><td><a href="https://steemit.com/halloween/@steemitboard/trick-or-treat-publish-your-scariest-halloweeen-story-and-win-a-new-badge" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Trick or Treat - Publish your scariest halloween story and win a new badge<tr><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-notifications-improved" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/NgygYH.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/NgygYH.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/64x128/http://i.cubeupload.com/NgygYH.png 2x" /><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-notifications-improved" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard notifications improved <blockquote> <p dir="auto">Support <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard's project! <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!