5 ### [Keys](https://bytom.github.io/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/list/resetPassword` the key. Please check the
11 [API doc](https://bytom.github.io/node-sdk/module-KeysApi.html) if you want
14 ### [Account](https://bytom.github.io/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/node-sdk/module-AccountsApi.html)
21 ### [Asset](https://bytom.github.io/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/node-sdk/module-AssetsApi.html)
29 ### [Transaction](https://bytom.github.io/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/node-sdk/module-TransactionsApi.html)
35 ### [Unspent Output(UTXO)](https://bytom.github.io/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/node-sdk/module-UnspentOutputsApi.html)
41 ### [Balance](https://bytom.github.io/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/node-sdk/module-BalancesApi.html)
53 const bytom = require('bytom-sdk')
54 const url = 'http://localhost:9888'
56 // access token is required when client is not in same origin
57 // with the request bytom node
58 const accessToken = ''
60 const client = new bytom.Client(url, accessToken)
63 ## Interaction with bytom
65 We will walk you through the process to issue some assets.
67 ### Step 1: create a key
70 const keyPromise = client.keys.create('alias', 'password')
73 It will create a key whose alias is 'alias' while password is 'password'.
75 ### Step 2: create a account
78 const accountPromise = keyPromise.then(key => {
79 client.accounts.create([key.xpub], 1, 'account')
83 ### Step 3: create account address
85 const addressPromise = accountPromise.then(account => {
86 return client.accounts.createReceiverById(account.id)
89 ### Step 4: create asset
98 const assetPromise = keyPromise.then(key => {
99 return client.assets.create([key.xpub], 1, 'asset', definition)
103 ### Step 5: issue asset
105 #### First, build the transaction
108 const buildPromise = Promise.all([
112 ).then(([account, address, asset]) => {
113 const issueAction = {
115 asset_alias: asset.alias,
120 type: 'spend_account',
121 account_alias: account.alias,
126 const controlAction = {
127 type: 'control_address',
129 asset_alias: asset.alias,
130 address: address.address
133 return client.transactions.build(null,
134 [issueAction, gasAction, controlAction])
139 #### Second, sign the transaction
142 const signPromise = buildPromise.then(transactionTemplate => {
143 return client.transactions.sign(transactionTemplate, 'password')
147 #### Finally, submit the signed transaction to the bytom network
150 signPromise.then(signed => {
151 return client.transactions.submit(signed.transaction.raw_transaction)