6 <meta name="viewport" content="width=device-width">
7 <title>Bytom Node.js SDK Module: TransactionsApi</title>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
12 <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
14 <link type="text/css" rel="stylesheet" href="styles/site.cosmo.css">
20 <div class="navbar navbar-default navbar-fixed-top ">
21 <div class="container">
22 <div class="navbar-header">
23 <a class="navbar-brand" href="index.html">Bytom Node.js SDK</a>
24 <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
25 <span class="icon-bar"></span>
26 <span class="icon-bar"></span>
27 <span class="icon-bar"></span>
30 <div class="navbar-collapse collapse" id="topNavigation">
31 <ul class="nav navbar-nav">
34 <a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
35 <ul class="dropdown-menu ">
36 <li><a href="module-AccessTokensApi.html">AccessTokensApi</a></li><li><a href="module-AccountsApi.html">AccountsApi</a></li><li><a href="module-AssetsApi.html">AssetsApi</a></li><li><a href="module-BalancesApi.html">BalancesApi</a></li><li><a href="module-KeysApi.html">KeysApi</a></li><li><a href="module-TransactionsApi.html">TransactionsApi</a></li><li><a href="module-UnspentOutputsApi.html">UnspentOutputsApi</a></li>
41 <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
42 <ul class="dropdown-menu ">
43 <li><a href="global.html">Global</a></li>
49 <div class="col-sm-3 col-md-3">
50 <form class="navbar-form" role="search">
51 <div class="input-group">
52 <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
53 <div class="input-group-btn">
54 <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
66 <div class="container" id="toc-content">
70 <div class="col-md-8">
75 <h1 class="page-title">Module: TransactionsApi</h1>
84 <div class="container-overview">
87 <div class="description"><p>API for interacting with <a href="global.html#Transaction">transactions</a>.</p></div>
147 <h3 class="subsection-title">Methods</h3>
153 <h4 class="name" id="~build"><span class="type-signature"><inner> </span>build(baseTransaction, actions, ttl)</h4>
160 <div class="description">
161 <p>Build an unsigned transaction from a set of actions and base transction(possibly null).</p>
174 <table class="params table table-striped">
187 <th class="last">Description</th>
196 <td class="name"><code>baseTransaction</code></td>
202 <span class="param-type">String</span>
213 <td class="description last"><p>Encoded base raw transaction.</p></td>
220 <td class="name"><code>actions</code></td>
226 <span class="param-type">Array.<<a href="module-TransactionsApi.html#~Action">module:TransactionsApi~Action</a>></span>
237 <td class="description last"><p>Set of actions to compose the transaction.</p></td>
244 <td class="name"><code>ttl</code></td>
250 <span class="param-type">Number</span>
261 <td class="description last"><p>Time duration to spent UTXOs will be reserverd(can't be spent during this time duration).</p></td>
324 <div class="param-desc">
326 <li>Unsigned transaction template.</li>
338 <span class="param-type">Promise.<Object></span>
355 <h4 class="name" id="~estimateGas"><span class="type-signature"><inner> </span>estimateGas(transaction)</h4>
362 <div class="description">
363 <p>Estimate how much gas one trasaction may use.</p>
376 <table class="params table table-striped">
389 <th class="last">Description</th>
398 <td class="name"><code>transaction</code></td>
404 <span class="param-type">Object</span>
415 <td class="description last"><p>The transaction template to estimate.</p></td>
478 <div class="param-desc">
479 <p>Estimation result.</p>
490 <span class="param-type">Object</span>
507 <h4 class="name" id="~listAll"><span class="type-signature"><inner> </span>listAll()</h4>
514 <div class="description">
515 <p>List all local transactions.</p>
580 <div class="param-desc">
581 <p>All local transactions.</p>
592 <span class="param-type">Promise.<Array.<<a href="global.html#Transaction">Transaction</a>>></span>
609 <h4 class="name" id="~listByAccountId"><span class="type-signature"><inner> </span>listByAccountId(accountId)</h4>
616 <div class="description">
617 <p>List all local transactions by account id.</p>
630 <table class="params table table-striped">
643 <th class="last">Description</th>
652 <td class="name"><code>accountId</code></td>
658 <span class="param-type">String</span>
669 <td class="description last"><p>Account id.</p></td>
732 <div class="param-desc">
733 <p>The result transactions.</p>
744 <span class="param-type">Promise.<Array.<<a href="global.html#Transaction">Transaction</a>>></span>
761 <h4 class="name" id="~listById"><span class="type-signature"><inner> </span>listById(id)</h4>
768 <div class="description">
769 <p>List local transactions by id.</p>
782 <table class="params table table-striped">
795 <th class="last">Description</th>
804 <td class="name"><code>id</code></td>
810 <span class="param-type">String</span>
821 <td class="description last"><p>The transaction id.</p></td>
884 <div class="param-desc">
885 <p>The result transactions.</p>
896 <span class="param-type">Promise.<Array.<<a href="global.html#Transaction">Transaction</a>>></span>
913 <h4 class="name" id="~sign"><span class="type-signature"><inner> </span>sign(transaction, password)</h4>
920 <div class="description">
921 <p>Sign transaction.</p>
934 <table class="params table table-striped">
947 <th class="last">Description</th>
956 <td class="name"><code>transaction</code></td>
962 <span class="param-type">Object</span>
973 <td class="description last"><p>The built transaction template.</p></td>
980 <td class="name"><code>password</code></td>
986 <span class="param-type">Object</span>
997 <td class="description last"><p>Password of the key which will sign the transaction template.</p></td>
1007 <dl class="details">
1060 <div class="param-desc">
1062 <li>Sign result.</li>
1074 <span class="param-type">Promise.<<a href="module-TransactionsApi.html#~SignResult">module:TransactionsApi~SignResult</a>></span>
1091 <h4 class="name" id="~submit"><span class="type-signature"><inner> </span>submit(raw_transaction)</h4>
1098 <div class="description">
1099 <p>Submit a signed transaction to the blockchain.</p>
1109 <h5>Parameters:</h5>
1112 <table class="params table table-striped">
1125 <th class="last">Description</th>
1134 <td class="name"><code>raw_transaction</code></td>
1140 <span class="param-type">String</span>
1151 <td class="description last"><p>Encoded fully signed transaction.</p></td>
1161 <dl class="details">
1214 <div class="param-desc">
1215 <p>Submit result. It will return tx_id if submit successfully else error.</p>
1226 <span class="param-type">Promise.<Object></span>
1243 <h3 class="subsection-title">Type Definitions</h3>
1248 <dt class="name" id="~Action">
1249 <h4 id="~Action">Action</h4>
1255 <div class="description">
1256 <p>Basic unit to build a transaction.
1257 For spend transaction, either account_id or account_alias is required to specify account info.
1258 Asset info(either asset_id or asset_alias ) is required for all kinds of action.</p>
1267 <span class="param-type">Object</span>
1276 <dl class="details">
1279 <h5 class="subsection-title">Properties:</h5>
1283 <table class="props table table-striped">
1296 <th class="last">Description</th>
1305 <td class="name"><code>type</code></td>
1311 <span class="param-type">String</span>
1322 <td class="description last"><p>Currently 4 types of action is supported:</p>
1324 <li>spend_account: action to spend UTXO from account.</li>
1325 <li>issue: action to issue asset.</li>
1326 <li>retire: action to retire asset.</li>
1327 <li>control_address: action to receive asset with address.</li>
1335 <td class="name"><code>account_alias</code></td>
1341 <span class="param-type">String</span>
1352 <td class="description last"><p>The alias of the account transferring the asset (possibly null).</p></td>
1359 <td class="name"><code>account_id</code></td>
1365 <span class="param-type">String</span>
1376 <td class="description last"><p>The id of the account transferring the asset (possibly null).</p></td>
1383 <td class="name"><code>asset_id</code></td>
1389 <span class="param-type">String</span>
1400 <td class="description last"><p>The id of the asset being issued or spent (possibly null).</p></td>
1407 <td class="name"><code>asset_alias</code></td>
1413 <span class="param-type">String</span>
1424 <td class="description last"><p>The alias of the asset being issued or spent (possibly null).</p></td>
1431 <td class="name"><code>address</code></td>
1437 <span class="param-type">String</span>
1448 <td class="description last"><p>Address to receive the transfered asset(possibly null, required for control_address action).</p></td>
1500 <dt class="name" id="~SignResult">
1501 <h4 id="~SignResult">SignResult</h4>
1507 <div class="description">
1508 <p>Data structure <code>/sign-transaction</code> api will return.</p>
1517 <span class="param-type">Object</span>
1526 <dl class="details">
1529 <h5 class="subsection-title">Properties:</h5>
1533 <table class="props table table-striped">
1546 <th class="last">Description</th>
1555 <td class="name"><code>transaction</code></td>
1561 <span class="param-type"><a href="global.html#Transaction">Transaction</a></span>
1572 <td class="description last"><p>The signed transaction if sign success.</p></td>
1579 <td class="name"><code>sign_complete</code></td>
1585 <span class="param-type">Boolean</span>
1596 <td class="description last"><p>Whether all input actions are signed. It means this transaction can be submit if true, else not.</p></td>
1659 <div class="clearfix"></div>
1662 <div class="col-md-3">
1663 <div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
1671 <div class="modal fade" id="searchResults">
1672 <div class="modal-dialog">
1673 <div class="modal-content">
1674 <div class="modal-header">
1675 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
1676 <h4 class="modal-title">Search results</h4>
1678 <div class="modal-body"></div>
1679 <div class="modal-footer">
1680 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
1682 </div><!-- /.modal-content -->
1683 </div><!-- /.modal-dialog -->
1690 <span class="jsdoc-message">
1691 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
1693 on 2018-05-24T14:05:00+08:00
1695 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
1699 <script src="scripts/docstrap.lib.js"></script>
1700 <script src="scripts/toc.js"></script>
1702 <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
1707 $( "[id*='$']" ).each( function () {
1708 var $this = $( this );
1710 $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
1713 $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
1714 var $this = $( this );
1716 var example = $this.find( "code" );
1717 exampleText = example.html();
1718 var lang = /{@lang (.*?)}/.exec( exampleText );
1719 if ( lang && lang[1] ) {
1720 exampleText = exampleText.replace( lang[0], "" );
1721 example.html( exampleText );
1724 var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
1725 lang = langClassMatch ? langClassMatch[1] : "javascript";
1731 .addClass( "sunlight-highlight-" + lang )
1732 .addClass( "linenums" )
1733 .html( example.html() );
1738 Sunlight.highlightAll( {
1741 enableDoclinks : true
1744 $.catchAnchorLinks( {
1748 anchorName : function ( i, heading, prefix ) {
1749 return $( heading ).attr( "id" ) || ( prefix + i );
1751 selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
1752 showAndHide : false,
1753 smoothScrolling: true
1756 $( "#main span[id^='toc']" ).addClass( "toc-shim" );
1757 $( '.dropdown-toggle' ).dropdown();
1759 $( "table" ).each( function () {
1760 var $this = $( this );
1761 $this.addClass('table');
1769 <!--Navigation and Symbol Display-->
1772 <!--Google Analytics-->
1776 <script type="text/javascript">
1777 $(document).ready(function() {
1778 SearcherDisplay.init();