5 ### [Keys](https://bytom.github.io/bytom-node-sdk/global.html#Key__anchor)
7 Cryptographic keys are the primary authorization mechanism on a blockchain.
9 To create accounts or assets, xpub of keys are required. With this sdk, we can
10 `create/delete/listAll/resetPassword/checkPassword` the key. Please check the
11 [API doc](https://bytom.github.io/bytom-node-sdk/module-KeysApi.html) if you want
14 ### [Account](https://bytom.github.io/bytom-node-sdk/global.html#Account__anchor)
16 An account is an object in Bytom that tracks ownership of assets on a blockchain.
17 It's defined under one Bytom node created with one or serveral keys.
19 [Related API](https://bytom.github.io/bytom-node-sdk/module-AccountsApi.html)
21 ### [Asset](https://bytom.github.io/bytom-node-sdk/global.html#Asset__anchor)
23 An asset is a type of value that can be issued on a blockchain. All units of
24 a given asset are fungible. Units of an asset can be transacted directly
25 between parties without the involvement of the issuer.
27 [Related API](https://bytom.github.io/bytom-node-sdk/module-AssetsApi.html)
29 ### [Transaction](https://bytom.github.io/bytom-node-sdk/global.html#Transaction__anchor)
31 Blockchain is chain of blocks, while block consists of numbers of transactions.
33 [Related API](https://bytom.github.io/bytom-node-sdk/module-TransactionsApi.html)
35 ### [Unspent Output(UTXO)](https://bytom.github.io/bytom-node-sdk/global.html#UnspentOutput__anchor)
37 Bytom is UTXO based blockchain. One transaction spend some UTXOs, and produces new UTXOs.
39 [Related API](https://bytom.github.io/bytom-node-sdk/module-UnspentOutputsApi.html)
41 ### [Balance](https://bytom.github.io/bytom-node-sdk/global.html#Balance__anchor)
43 Any balance on the blockchain is simply a summation of UTXOs. In one bytomd, balance means
44 summation of UTXOs of one account.
46 [Related API](https://bytom.github.io/bytom-node-sdk/module-BalancesApi.html)
48 ### [Block](https://bytom.github.io/bytom-node-sdk/global.html#Block__anchor)
50 A block is a container data structure that aggregates transactions for inclusion in the public ledger, the blockchain.
51 It is made of a header, containing metadata, followed by a long list of transactions that make up the bulk of its size.
52 Each block references to the previous block, and all the blocks are linked from the back to the front to grow a blockchain.
54 [Related API](https://bytom.github.io/bytom-node-sdk/module-BlockApi.html)
56 ### [Config](https://bytom.github.io/bytom-node-sdk/global.html#Config__anchor)
58 Config contain the network information that you wanted to know.
60 [Related API](https://bytom.github.io/bytom-node-sdk/module-ConfigApi.html)
67 const bytom = require('bytom-sdk')
68 const url = 'http://localhost:9888'
70 // access token is required when client is not in same origin
71 // with the request bytom node
72 const accessToken = ''
74 const client = new bytom.Client(url, accessToken)
77 ## Interaction with bytom
79 We will walk you through the process to issue some assets.
81 ### Step 1: create a key
84 const keyPromise = client.keys.create({
90 It will create a key whose alias is 'alias' while password is 'password'.
92 ### Step 2: create a account
95 const accountPromise = keyPromise.then(key => {
96 client.accounts.create({
98 root_xpubs: [key.xpub],
104 ### Step 3: create account address
107 const addressPromise = accountPromise.then(account => {
108 return client.accounts.createReceiver({
109 account_alias: account.alias
114 ### Step 4: create asset
124 const assetPromise = keyPromise.then(key => {
125 return client.assets.create(
129 root_xpubs: [key.xpub],
135 ### Step 5: issue asset
137 #### First, build the transaction
140 const buildPromise = Promise.all([
144 ).then(([account, address, asset]) => {
145 const issueAction = {
147 asset_alias: asset.alias,
151 account_alias: account.alias,
156 const controlAction = {
158 asset_alias: asset.alias,
159 address: address.address
162 return client.transactions.build(builder => {
163 builder.issue(issueAction)
164 builder.spendFromAccount(gasAction)
165 builder.controlWithAddress(controlAction)
171 #### Second, sign the transaction
174 const signPromise = buildPromise.then(transactionTemplate => {
175 return client.transactions.sign({
176 transaction: transactionTemplate,
182 #### Finally, submit the signed transaction to the bytom network
185 signPromise.then(signed => {
186 return client.transactions.submit(signed.transaction.raw_transaction)