From: Yongfeng LI Date: Thu, 24 May 2018 06:05:15 +0000 (+0800) Subject: update doc X-Git-Tag: v1.0.2~5 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fbytom-node-sdk.git;a=commitdiff_plain;h=e43c45dd683b81fbc98a2fe4127ba0a864de9194 update doc --- diff --git a/docs/global.html b/docs/global.html index bd60b96..9c743b9 100644 --- a/docs/global.html +++ b/docs/global.html @@ -2730,7 +2730,7 @@ the unspent output set.

Documentation generated by JSDoc 3.5.5 - on 2018-05-21T13:04:20+08:00 + on 2018-05-24T14:04:59+08:00 using the DocStrap template. diff --git a/docs/index.html b/docs/index.html index c637ccc..e900eee 100644 --- a/docs/index.html +++ b/docs/index.html @@ -93,40 +93,51 @@
-

Bytom Node.js SDK

Terminology

Keys

Cryptographic keys are the primary authorization mechanism on a blockchain.

+

Bytom Node.js SDK

Terminology

Keys

Cryptographic keys are the primary authorization mechanism on a blockchain.

To create accounts or assets, xpub of keys are required. With this sdk, we can create/delete/list/resetPassword the key. Please check the -API doc if you want +API doc if you want to operate with keys.

-

Account

An account is an object in Bytom that tracks ownership of assets on a blockchain. +

Account

An account is an object in Bytom that tracks ownership of assets on a blockchain. It's defined under one Bytom node created with one or serveral keys.

-

Related API

-

Asset

An asset is a type of value that can be issued on a blockchain. All units of +

Related API

+

Asset

An asset is a type of value that can be issued on a blockchain. All units of a given asset are fungible. Units of an asset can be transacted directly between parties without the involvement of the issuer.

-

Related API

-

Transaction

Blockchain is chain of blocks, while block consists of numbers of transactions.

-

Related API

-

Unspent Output(UTXO)

Bytom is UTXO based blockchain. One transaction spend some UTXOs, and produces new UTXOs.

-

Related API

-

Balance

Any balance on the blockchain is simply a summation of UTXOs. In one bytomd, balance means +

Related API

+

Transaction

Blockchain is chain of blocks, while block consists of numbers of transactions.

+

Related API

+

Unspent Output(UTXO)

Bytom is UTXO based blockchain. One transaction spend some UTXOs, and produces new UTXOs.

+

Related API

+

Balance

Any balance on the blockchain is simply a summation of UTXOs. In one bytomd, balance means summation of UTXOs of one account.

-

Related API

-

Usage

In your code

const bytom = require('bytom-sdk')
+

Related API

+

Usage

In your code

const bytom = require('bytom-sdk')
 const url = 'http://localhost:9888'
 
-// access token is required when client is not in same origin with the request bytom node
+// access token is required when client is not in same origin
+// with the request bytom node
 const accessToken = ''
 
 const client = new bytom.Client(url, accessToken)

Interaction with bytom

We will walk you through the process to issue some assets.

Step 1: create a key

const keyPromise = client.keys.create('alias', 'password')

It will create a key whose alias is 'alias' while password is 'password'.

-

Step 2: create a account

const accountPromise = keyPromise.then(key => client.accounts.create([key.xpub], 1, 'account'))

Step 3: create account address

const addressPromise = accountPromise.then(account => { +

Step 2: create a account

const accountPromise = keyPromise.then(key => {
+ client.accounts.create([key.xpub], 1, 'account')
+})

Step 3: create account address

const addressPromise = accountPromise.then(account => {
   return client.accounts.createReceiverById(account.id)
-})

-

Step 4: create asset

const definition = {name: "GOLD", symobol: "GOLD", decimals: 8, description: {}}
+})

Step 4: create asset

const definition = {
+  name: "GOLD",
+  symobol: "GOLD",
+  decimals: 8,
+  description: {}
+}
 const assetPromise = keyPromise.then(key => {
   return client.assets.create([key.xpub], 1, 'asset', definition)
-})

Step 5: issue asset

First, build the transaction

const buildPromise = Promise.all([accountPromise, addressPromise, assetPromise]).then(([account, address, asset]) => {
+})

Step 5: issue asset

First, build the transaction

const buildPromise = Promise.all([
+  accountPromise,
+  addressPromise,
+  assetPromise]
+  ).then(([account, address, asset]) => {
   const issueAction = {
     amount: 10000000000,
     asset_alias: asset.alias,
@@ -147,7 +158,8 @@ const assetPromise = keyPromise.then(key => {
     address: address.address
   }
 
-  return client.transactions.build(null, [issueAction, gasAction, controlAction])
+  return client.transactions.build(null,
+  [issueAction, gasAction, controlAction])
 })
 

Second, sign the transaction

const signPromise = buildPromise.then(transactionTemplate => {
   return client.transactions.sign(transactionTemplate, 'password')
@@ -199,7 +211,7 @@ const assetPromise = keyPromise.then(key => {
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:20+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-AccessTokensApi.html b/docs/module-AccessTokensApi.html
index 29f5bec..58e9c8a 100644
--- a/docs/module-AccessTokensApi.html
+++ b/docs/module-AccessTokensApi.html
@@ -578,7 +578,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-AccountsApi.html b/docs/module-AccountsApi.html
index 41d05fa..489565c 100644
--- a/docs/module-AccountsApi.html
+++ b/docs/module-AccountsApi.html
@@ -1562,7 +1562,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-AssetsApi.html b/docs/module-AssetsApi.html
index 1b14912..5ace80b 100644
--- a/docs/module-AssetsApi.html
+++ b/docs/module-AssetsApi.html
@@ -1185,7 +1185,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-BalancesApi.html b/docs/module-BalancesApi.html
index 8220637..97b4bd1 100644
--- a/docs/module-BalancesApi.html
+++ b/docs/module-BalancesApi.html
@@ -298,7 +298,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-KeysApi.html b/docs/module-KeysApi.html
index df09837..e74dfb2 100644
--- a/docs/module-KeysApi.html
+++ b/docs/module-KeysApi.html
@@ -798,7 +798,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-TransactionsApi.html b/docs/module-TransactionsApi.html
index d7ea84b..e65a763 100644
--- a/docs/module-TransactionsApi.html
+++ b/docs/module-TransactionsApi.html
@@ -1690,7 +1690,7 @@ Asset info(either asset_id or asset_alias ) is required for all kinds of action.
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/module-UnspentOutputsApi.html b/docs/module-UnspentOutputsApi.html
index 7b3fe69..719ab7a 100644
--- a/docs/module-UnspentOutputsApi.html
+++ b/docs/module-UnspentOutputsApi.html
@@ -450,7 +450,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:21+08:00
+		on 2018-05-24T14:05:00+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/modules.list.html b/docs/modules.list.html
index cf01d6d..ce90ecd 100644
--- a/docs/modules.list.html
+++ b/docs/modules.list.html
@@ -195,7 +195,7 @@
 
 	Documentation generated by JSDoc 3.5.5
 	
-		on 2018-05-21T13:04:20+08:00
+		on 2018-05-24T14:04:59+08:00
 	
 	using the DocStrap template.
 
diff --git a/docs/quicksearch.html b/docs/quicksearch.html
index 43dafac..050b7e5 100644
--- a/docs/quicksearch.html
+++ b/docs/quicksearch.html
@@ -7,7 +7,7 @@