create account

BTSDEX v0.6.0 by scientistnik

View this thread on: hive.blogpeakd.comecency.com
· @scientistnik ·
$2.36
BTSDEX v0.6.0
![BTSDEX.png](https://cdn.steemitimages.com/DQmWRd3fqRBT4ixj4RKE6gE1qLo1fbnrLFHuPLk2JZYKZxn/BTSDEX.png)

Here comes the new version of the `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.

## Loss of compatibility

In all previous versions, before using the `BitShares` class, it was necessary to initialize it:

```js
BitShares.init(<node>, <autoconnect>, <autoreconnect>)
```
Now this method is not. But the `connect` method has been enriched with parameters:
```js
BitShares.connect(<node>, <autoreconnect>)
```

If you use an event system to connection, and you want to specify connection parameters, use `BitShares.node` and` BitShares.autoreconnect` to do this.

```js
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
}
```

This is the only incompatibility with other versions.

## Transaction builder

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.

To create a new transaction:
```js
let tx = BitShares.newTx([<activePrivateKey>, ...])
```
or if you already have an instance of the `BitShares` class:
```js
let acc = await BitShares.login(<accountName>, <password>);
let tx = acc.newTx()
```

Each operation available out of the box has a method (`<name>Operation`) that forms the operation object, but does not send it to the blockchain.

To obtain the objects of operations:
```js
let operation1 = await acc.transferOperation("scientistnik", "BTS", 10)
let operation2 = await acc.assetIssueOperation("scientistnik", "ABC", 10)
...
```
Adding operations to a transaction:
```js
tx.add(operation1)
tx.add(operation2)
...
```
You can get the cost of the transaction:
```js
let cost = await tx.cost()
console.log(cost) // {BTS: 1.234}
```
After that, the transaction can be sent:
```js
await tx.broadcast()
```
or
```js
await acc.broadcast(tx)
```

The operations available to the account in the BitShares network are much more than the available object of the class `BitShares`. If you know which fields are necessary for an operation, you can use the transaction builder to submit this operation.

Example of creating a new account:
```js
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()
}
```

## One-time request in REPL mode

If you only need to make one request, you can use `--account`,` --asset`, `--block`,` --object`, `--history`,` --node` or `--transfer` command line keys:
```js
$ 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>'
```

## Documentation Update

Updated [documentation](https://scientistnik.github.io/btsdex/#/), added its [Russian version](https://scientistnik.github.io/btsdex/#/ru/).

<hr>

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 [btsdex](https://t.me/btsdex).

I have it all. Great weekend to everyone!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 28 others
properties (23)
authorscientistnik
permlinkbtsdex-v0-6-0
categoryutopian-io
json_metadata{"tags":["utopian-io","bitshares","blockchain"],"image":["https://cdn.steemitimages.com/DQmWRd3fqRBT4ixj4RKE6gE1qLo1fbnrLFHuPLk2JZYKZxn/BTSDEX.png"],"links":["https://scientistnik.github.io/btsdex/#/","https://scientistnik.github.io/btsdex/#/ru/","https://t.me/btsdex"],"app":"steemit/0.1","format":"markdown"}
created2018-10-28 14:58:27
last_update2018-10-28 14:58:27
depth0
children1
last_payout2018-11-04 14:58:27
cashout_time1969-12-31 23:59:59
total_payout_value1.834 HBD
curator_payout_value0.521 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,171
author_reputation748,919,157,653
root_title"BTSDEX v0.6.0"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,216,777
net_rshares2,046,110,060,117
author_curate_reward""
vote details (92)
@steemitboard ·
Congratulations @scientistnik! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td>https://steemitimages.com/60x70/http://steemitboard.com/@scientistnik/voted.png?201810282336</td><td>You received more than 250 upvotes. Your next target is to reach 500 upvotes.</td></tr>
</table>

<sub>_[Click here to view your Board of Honor](https://steemitboard.com/@scientistnik)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the last post from @steemitboard:**
<table><tr><td><a href="https://steemit.com/halloween/@steemitboard/trick-or-treat-publish-your-scariest-halloweeen-story-and-win-a-new-badge"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/RUyB3u.png"></a></td><td><a href="https://steemit.com/halloween/@steemitboard/trick-or-treat-publish-your-scariest-halloweeen-story-and-win-a-new-badge">Trick or Treat - Publish your scariest halloween story and win a new badge</a></td></tr><tr><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-notifications-improved"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/NgygYH.png"></a></td><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-notifications-improved">SteemitBoard notifications improved</a></td></tr></table>

> Support [SteemitBoard's project](https://steemit.com/@steemitboard)! **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-scientistnik-20181029t001214000z
categoryutopian-io
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2018-10-29 00:12:12
last_update2018-10-29 00:12:12
depth1
children0
last_payout2018-11-05 00:12:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,616
author_reputation38,975,615,169,260
root_title"BTSDEX v0.6.0"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id74,241,510
net_rshares0