bdcontract-web-ide/doc/markdown_BDWare/httpapi.html

738 lines
30 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Request Examples {#_request_examples} &mdash; 北大数瑞大数据区块链 V1.0 文档</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/translations.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="index" title="索引" href="../genindex.html" />
<link rel="search" title="搜索" href="../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html">
<img src="../_static/logo.png" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="在文档中搜索" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">目录</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Introduction.html">BDContract介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="../InstallTips.html">BDContract安装说明</a></li>
<li class="toctree-l1"><a class="reference internal" href="../IDEUsage.html">BDContract管理界面</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ContractAPI.html">BDContract SDK</a></li>
<li class="toctree-l1"><a class="reference internal" href="../YJSInDepth.html">YJS语法</a></li>
<li class="toctree-l1"><a class="reference internal" href="../YJSAPI.html">YJS SDK</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">北大数瑞大数据区块链</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>Request Examples {#_request_examples}</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/markdown_BDWare/httpapi.md.txt" rel="nofollow"> 查看页面源码</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="highlight-{.yaml} notranslate"><div class="highlight"><pre><span></span>type: google.api.Service
config_version: 3
http:
rules:
- selector: bdware.bdledger.api.Node.ClientVersion
get: /v0/node/version
- selector: bdware.bdledger.api.Ledger.CreateLedger
post: /v0/ledgers
body: &quot;*&quot;
- selector: bdware.bdledger.api.Ledger.GetLedgers
get: /v0/ledgers
- selector: bdware.bdledger.api.Ledger.SendTransaction
post: /v0/ledgers/{ledger}/transactions
body: &quot;*&quot;
- selector: bdware.bdledger.api.Query.GetBlockByHash
get: /v0/ledgers/{ledger}/block
- selector: bdware.bdledger.api.Query.GetBlocks
post: /v0/ledgers/{ledger}/blocks/query
body: &quot;*&quot;
- selector: bdware.bdledger.api.Query.CountBlocks
post: /v0/ledgers/{ledger}/blocks/count
body: &quot;*&quot;
- selector: bdware.bdledger.api.Query.GetRecentBlocks
get: /v0/ledgers/{ledger}/blocks/recent
- selector: bdware.bdledger.api.Query.GetTransactionByHash
get: /v0/ledgers/{ledger}/transaction
- selector: bdware.bdledger.api.Query.GetTransactionByBlockHashAndIndex
get: /v0/ledgers/{ledger}/block/transaction
- selector: bdware.bdledger.api.Query.GetTransactions
post: /v0/ledgers/{ledger}/transactions/query
body: &quot;*&quot;
- selector: bdware.bdledger.api.Query.CountTransactions
post: /v0/ledgers/{ledger}/transactions/count
body: &quot;*&quot;
</pre></div>
</div>
<blockquote>
<div><p><strong>Note</strong></p>
<p>Request/Response data of <strong>bytes</strong> type should/will be encoded with
<a class="reference external" href="https://tools.ietf.org/html/rfc4648#section-4">Base64</a>.</p>
</div></blockquote>
<blockquote>
<div><p><strong>Note</strong></p>
<p>When using hash strings in URL, they need to be encoded with
<a class="reference external" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a>.</p>
</div></blockquote>
<div class="section" id="request-examples-request-examples">
<h1>Request Examples {#_request_examples}<a class="headerlink" href="#request-examples-request-examples" title="永久链接至标题"></a></h1>
<div class="section" id="node-clientversion-node-clientversion">
<h2>Node.ClientVersion {#_node_clientversion}<a class="headerlink" href="#node-clientversion-node-clientversion" title="永久链接至标题"></a></h2>
<p>Get BDLedger node version</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">GET</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">node</span><span class="o">/</span><span class="n">version</span>
</pre></div>
</div>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;version&quot;: &quot;dev-210119.a88bf4eb&quot;
}
</pre></div>
</div>
</div>
<div class="section" id="ledger-createledger-ledger-createledger">
<h2>Ledger.CreateLedger {#_ledger_createledger}<a class="headerlink" href="#ledger-createledger-ledger-createledger" title="永久链接至标题"></a></h2>
<p>Create a new ledger</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span>
</pre></div>
</div>
<p><strong>Request body.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;name&quot;: &quot;test&quot;
}
</pre></div>
</div>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;ok&quot;: true
}
</pre></div>
</div>
</div>
<div class="section" id="ledger-getledgers-ledger-getledgers">
<h2>Ledger.GetLedgers {#_ledger_getledgers}<a class="headerlink" href="#ledger-getledgers-ledger-getledgers" title="永久链接至标题"></a></h2>
<p>Get all ledgers</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">GET</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span>
</pre></div>
</div>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;ledgers&quot;: [
&quot;default&quot;,
&quot;test&quot;
]
}
</pre></div>
</div>
</div>
<div class="section" id="ledger-sendtransaction-ledger-sendtransaction">
<h2>Ledger.SendTransaction {#_ledger_sendtransaction}<a class="headerlink" href="#ledger-sendtransaction-ledger-sendtransaction" title="永久链接至标题"></a></h2>
<p>Send a new transaction</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">transactions</span>
</pre></div>
</div>
<p><strong>Request body.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;transaction&quot;: {
&quot;type&quot;: 0,
&quot;from&quot;: &quot;8A3K/vANyv7wDcr+8A3K/vANyv4=&quot;,
&quot;nonce&quot;: 52,
&quot;data&quot;: &quot;lQItWZKS5hlUn6V/DMKKwvZXxvM=&quot;
}
}
</pre></div>
</div>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;hash&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;
}
</pre></div>
</div>
</div>
<div class="section" id="query-getblockbyhash-query-getblockbyhash">
<h2>Query.GetBlockByHash {#_query_getblockbyhash}<a class="headerlink" href="#query-getblockbyhash-query-getblockbyhash" title="永久链接至标题"></a></h2>
<p>Get a block identified by its hash</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/block?hash=LSKr%2BK079Ax%2BrKdlyYN5ze2YGzo%3D
</pre></div>
</div>
<p><strong>hash</strong> has to be encoded with
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a></p>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;block&quot;: {
&quot;hash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;creator&quot;: &quot;&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;parentHashes&quot;: [
&quot;fLX5pMY8M1qSAGZdKT1rWBkdEMo=&quot;,
&quot;rk0DWMaUpRG82yVX+cFhbfhPFdw=&quot;,
&quot;3XkwkuMBearq8uavN76Te7Zdpl8=&quot;
],
&quot;witnesses&quot;: [],
&quot;timestamp&quot;: &quot;1611038043&quot;,
&quot;size&quot;: &quot;0&quot;,
&quot;transactionCount&quot;: 1,
&quot;transactionsRoot&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;transactions&quot;: [
{
&quot;blockHash&quot;: &quot;&quot;,
&quot;blockTimestamp&quot;: &quot;0&quot;,
&quot;index&quot;: 0,
&quot;hash&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;type&quot;: &quot;RECORD&quot;,
&quot;from&quot;: &quot;8A3K/vANyv7wDcr+8A3K/vANyv4=&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;to&quot;: &quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,
&quot;data&quot;: &quot;lQItWZKS5hlUn6V/DMKKwvZXxvM=&quot;
}
],
&quot;transactionHashes&quot;: [
&quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;
]
}
}
</pre></div>
</div>
</div>
<div class="section" id="query-getblocks-query-getblocks">
<h2>Query.GetBlocks {#_query_getblocks}<a class="headerlink" href="#query-getblocks-query-getblocks" title="永久链接至标题"></a></h2>
<p>Get blocks in a timestamp range</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">blocks</span><span class="o">/</span><span class="n">query</span>
</pre></div>
</div>
<div class="highlight-{.protobuf} notranslate"><div class="highlight"><pre><span></span>enum IncludeTransactions {
NONE = 0; // Don&#39;t include transaction data
HASH = 1; // Include transactions hashes
FULL = 2; // Include full transactions
}
</pre></div>
</div>
<p>Requirement: asciimath:[“start_timestamp”⇐”end_timestamp”]</p>
<p>If only <strong>end_timestamp</strong> is not specified, or
asciimath:[“end_timestamp”-“start_timestamp”&gt;”query.maxDuration”],
then <strong>end_timestamp</strong> will be set to
asciimath:[“start_timestamp”+”query.maxDuration”].</p>
<p>If only <strong>start_timestamp</strong> is not specified, then <strong>start_timestamp</strong>
will be set to asciimath:[“end_timestamp”-“query.maxDuration”].</p>
<p>In all cases, <strong>start_timestamp</strong> will never be earlier than the
genesis blocks timestamp, and <strong>end_timestamp</strong> will never be later
than the current timestamp when the node process the query request.</p>
<p><strong>Request body 1.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;start_timestamp&quot;: 1611038000,
&quot;end_timestamp&quot;: 1611039000,
&quot;include_transactions&quot;: 0
}
</pre></div>
</div>
<p><strong>Response 1.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;blocks&quot;: [
{
&quot;hash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;creator&quot;: &quot;&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;parentHashes&quot;: [
&quot;fLX5pMY8M1qSAGZdKT1rWBkdEMo=&quot;,
&quot;rk0DWMaUpRG82yVX+cFhbfhPFdw=&quot;,
&quot;3XkwkuMBearq8uavN76Te7Zdpl8=&quot;
],
&quot;witnesses&quot;: [],
&quot;timestamp&quot;: &quot;1611038043&quot;,
&quot;size&quot;: &quot;0&quot;,
&quot;transactionCount&quot;: 1,
&quot;transactionsRoot&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;transactions&quot;: [],
&quot;transactionHashes&quot;: []
}
],
&quot;startTimestamp&quot;: &quot;1611038043&quot;,
&quot;endTimestamp&quot;: &quot;1611038043&quot;
}
</pre></div>
</div>
<p><strong>Request body 2.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;start_timestamp&quot;: 1611038000,
&quot;end_timestamp&quot;: 1611039000,
&quot;include_transactions&quot;: 1
}
</pre></div>
</div>
<p><strong>Response 2.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;blocks&quot;: [
{
&quot;hash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;creator&quot;: &quot;&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;parentHashes&quot;: [
&quot;fLX5pMY8M1qSAGZdKT1rWBkdEMo=&quot;,
&quot;rk0DWMaUpRG82yVX+cFhbfhPFdw=&quot;,
&quot;3XkwkuMBearq8uavN76Te7Zdpl8=&quot;
],
&quot;witnesses&quot;: [],
&quot;timestamp&quot;: &quot;1611038043&quot;,
&quot;size&quot;: &quot;0&quot;,
&quot;transactionCount&quot;: 1,
&quot;transactionsRoot&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;transactions&quot;: [],
&quot;transactionHashes&quot;: [
&quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;
]
}
],
&quot;startTimestamp&quot;: &quot;1611038043&quot;,
&quot;endTimestamp&quot;: &quot;1611038043&quot;
}
</pre></div>
</div>
<p><strong>Request body 3.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;start_timestamp&quot;: 1611038000,
&quot;end_timestamp&quot;: 1611039000,
&quot;include_transactions&quot;: 2
}
</pre></div>
</div>
<p><strong>Response 3.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;blocks&quot;: [
{
&quot;hash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;creator&quot;: &quot;&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;parentHashes&quot;: [
&quot;fLX5pMY8M1qSAGZdKT1rWBkdEMo=&quot;,
&quot;rk0DWMaUpRG82yVX+cFhbfhPFdw=&quot;,
&quot;3XkwkuMBearq8uavN76Te7Zdpl8=&quot;
],
&quot;witnesses&quot;: [],
&quot;timestamp&quot;: &quot;1611038043&quot;,
&quot;size&quot;: &quot;0&quot;,
&quot;transactionCount&quot;: 1,
&quot;transactionsRoot&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;transactions&quot;: [
{
&quot;blockHash&quot;: &quot;&quot;,
&quot;blockTimestamp&quot;: &quot;0&quot;,
&quot;index&quot;: 0,
&quot;hash&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;type&quot;: &quot;RECORD&quot;,
&quot;from&quot;: &quot;8A3K/vANyv7wDcr+8A3K/vANyv4=&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;to&quot;: &quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,
&quot;data&quot;: &quot;lQItWZKS5hlUn6V/DMKKwvZXxvM=&quot;
}
],
&quot;transactionHashes&quot;: [
&quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;
]
}
],
&quot;startTimestamp&quot;: &quot;1611038043&quot;,
&quot;endTimestamp&quot;: &quot;1611038043&quot;
}
</pre></div>
</div>
</div>
<div class="section" id="query-countblocks-query-countblocks">
<h2>Query.CountBlocks {#_query_countblocks}<a class="headerlink" href="#query-countblocks-query-countblocks" title="永久链接至标题"></a></h2>
<p>Count all blocks in a ledger, or blocks in a timestamp range</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">blocks</span><span class="o">/</span><span class="n">count</span>
</pre></div>
</div>
<p>Requirement: asciimath:[“start_timestamp”⇐”end_timestamp”]</p>
<p>If neither <strong>start_timestamp</strong> nor <strong>end_timestamp</strong> is specified,
then count all blocks in the specified ledger.</p>
<p>If only <strong>end_timestamp</strong> is not specified, then count all blocks with
timestamps later than <strong>start_timestamp</strong>.</p>
<p>If only <strong>start_timestamp</strong> is not specified, then count all blocks
with timestamps earlier than <strong>end_timestamp</strong>.</p>
<p>In all cases, <strong>start_timestamp</strong> will never be earlier than the
genesis blocks timestamp, and <strong>end_timestamp</strong> will never be later
than the current timestamp when the node process the query request.</p>
<p><strong>Request body 1.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{}
</pre></div>
</div>
<p><strong>Response 1.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;count&quot;: &quot;5&quot;,
&quot;startTimestamp&quot;: &quot;0&quot;,
&quot;endTimestamp&quot;: &quot;1611039957&quot;
}
</pre></div>
</div>
<p><strong>Request body 2.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;start_timestamp&quot;: 1611038000,
&quot;end_timestamp&quot;: 1611039000
}
</pre></div>
</div>
<p><strong>Response 2.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;count&quot;: &quot;1&quot;,
&quot;startTimestamp&quot;: &quot;1611038000&quot;,
&quot;endTimestamp&quot;: &quot;1611039000&quot;
}
</pre></div>
</div>
</div>
<div class="section" id="query-getrecentblocks-query-getrecentblocks">
<h2>Query.GetRecentBlocks {#_query_getrecentblocks}<a class="headerlink" href="#query-getrecentblocks-query-getrecentblocks" title="永久链接至标题"></a></h2>
<p>Get recent <strong>count</strong> blocks (Only support IncludeTransactions=NONE for
now)</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/blocks/recent?count=2
</pre></div>
</div>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;blocks&quot;: [
{
&quot;hash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;creator&quot;: &quot;&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;parentHashes&quot;: [
&quot;fLX5pMY8M1qSAGZdKT1rWBkdEMo=&quot;,
&quot;rk0DWMaUpRG82yVX+cFhbfhPFdw=&quot;,
&quot;3XkwkuMBearq8uavN76Te7Zdpl8=&quot;
],
&quot;witnesses&quot;: [],
&quot;timestamp&quot;: &quot;1611038043&quot;,
&quot;size&quot;: &quot;0&quot;,
&quot;transactionCount&quot;: 1,
&quot;transactionsRoot&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;transactions&quot;: [],
&quot;transactionHashes&quot;: []
},
{
&quot;hash&quot;: &quot;rk0DWMaUpRG82yVX+cFhbfhPFdw=&quot;,
&quot;creator&quot;: &quot;&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;parentHashes&quot;: [
&quot;fLX5pMY8M1qSAGZdKT1rWBkdEMo=&quot;,
&quot;3XkwkuMBearq8uavN76Te7Zdpl8=&quot;,
&quot;8pZPR74OALIbps5XFb4dL/s0j0M=&quot;
],
&quot;witnesses&quot;: [],
&quot;timestamp&quot;: &quot;1610968019&quot;,
&quot;size&quot;: &quot;0&quot;,
&quot;transactionCount&quot;: 1,
&quot;transactionsRoot&quot;: &quot;LuxttCm/pSHVMOKF0sJExk+DJXc=&quot;,
&quot;transactions&quot;: [],
&quot;transactionHashes&quot;: []
}
],
&quot;startTimestamp&quot;: &quot;1610968019&quot;,
&quot;endTimestamp&quot;: &quot;1611038043&quot;
}
</pre></div>
</div>
</div>
<div class="section" id="query-gettransactionbyhash-query-gettransactionbyhash">
<h2>Query.GetTransactionByHash {#_query_gettransactionbyhash}<a class="headerlink" href="#query-gettransactionbyhash-query-gettransactionbyhash" title="永久链接至标题"></a></h2>
<p>Get a transaction identified by its hash</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/transaction?hash=VQBeA5Ee0Y5hqEileoQuYMHbOSE%3D
</pre></div>
</div>
<p><strong>hash</strong> has to be encoded with
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a></p>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;transaction&quot;: {
&quot;blockHash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;blockTimestamp&quot;: &quot;1611038043&quot;,
&quot;index&quot;: 0,
&quot;hash&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;type&quot;: &quot;RECORD&quot;,
&quot;from&quot;: &quot;8A3K/vANyv7wDcr+8A3K/vANyv4=&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;to&quot;: &quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,
&quot;data&quot;: &quot;lQItWZKS5hlUn6V/DMKKwvZXxvM=&quot;
}
}
</pre></div>
</div>
</div>
<div class="section" id="query-gettransactionbyblockhashandindex-query-gettransactionbyblockhashandindex">
<h2>Query.GetTransactionByBlockHashAndIndex {#_query_gettransactionbyblockhashandindex}<a class="headerlink" href="#query-gettransactionbyblockhashandindex-query-gettransactionbyblockhashandindex" title="永久链接至标题"></a></h2>
<p>Get a transaction identified by hash of the block it belongs to and its
index inside the block</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/block/transaction?blockHash=LSKr%2BK079Ax%2BrKdlyYN5ze2YGzo%3D&amp;index=0
</pre></div>
</div>
<p><strong>blockHash</strong> has to be encoded with
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a></p>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;transaction&quot;: {
&quot;blockHash&quot;: &quot;LSKr+K079Ax+rKdlyYN5ze2YGzo=&quot;,
&quot;blockTimestamp&quot;: &quot;1611038043&quot;,
&quot;index&quot;: 0,
&quot;hash&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;type&quot;: &quot;RECORD&quot;,
&quot;from&quot;: &quot;8A3K/vANyv7wDcr+8A3K/vANyv4=&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;to&quot;: &quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,
&quot;data&quot;: &quot;lQItWZKS5hlUn6V/DMKKwvZXxvM=&quot;
}
}
</pre></div>
</div>
</div>
<div class="section" id="query-gettransactions-query-gettransactions">
<h2>Query.GetTransactions {#_query_gettransactions}<a class="headerlink" href="#query-gettransactions-query-gettransactions" title="永久链接至标题"></a></h2>
<p>Get transactions in a timestamp range</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">transactions</span><span class="o">/</span><span class="n">query</span>
</pre></div>
</div>
<p><strong>start_timestamp</strong> and <strong>end_timestamp</strong> follow the same requirements
and rules as in <a class="reference external" href="#Query.GetBlocks">???</a>.</p>
<p><strong>Request body.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;start_timestamp&quot;: 1611038000,
&quot;end_timestamp&quot;: 1611039000
}
</pre></div>
</div>
<p><strong>Response.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;transactions&quot;: [
{
&quot;blockHash&quot;: &quot;&quot;,
&quot;blockTimestamp&quot;: &quot;0&quot;,
&quot;index&quot;: 0,
&quot;hash&quot;: &quot;VQBeA5Ee0Y5hqEileoQuYMHbOSE=&quot;,
&quot;type&quot;: &quot;RECORD&quot;,
&quot;from&quot;: &quot;8A3K/vANyv7wDcr+8A3K/vANyv4=&quot;,
&quot;nonce&quot;: &quot;0&quot;,
&quot;to&quot;: &quot;AAAAAAAAAAAAAAAAAAAAAAAAAAA=&quot;,
&quot;data&quot;: &quot;lQItWZKS5hlUn6V/DMKKwvZXxvM=&quot;
}
],
&quot;startTimestamp&quot;: &quot;1611038043&quot;,
&quot;endTimestamp&quot;: &quot;1611038043&quot;
}
</pre></div>
</div>
</div>
<div class="section" id="query-counttransactions-query-counttransactions">
<h2>Query.CountTransactions {#_query_counttransactions}<a class="headerlink" href="#query-counttransactions-query-counttransactions" title="永久链接至标题"></a></h2>
<p>Count all transactions in a ledger, or transactions in a timestamp range</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">transactions</span><span class="o">/</span><span class="n">count</span>
</pre></div>
</div>
<p><strong>start_timestamp</strong> and <strong>end_timestamp</strong> follow the same requirements
and rules as in <a class="reference external" href="#Query.CountBlocks">???</a>.</p>
<p><strong>Request body 1.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{}
</pre></div>
</div>
<p><strong>Response 1.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;count&quot;: &quot;4&quot;,
&quot;startTimestamp&quot;: &quot;0&quot;,
&quot;endTimestamp&quot;: &quot;1611039957&quot;
}
</pre></div>
</div>
<p><strong>Request body 2.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;start_timestamp&quot;: 1611038000,
&quot;end_timestamp&quot;: 1611039000
}
</pre></div>
</div>
<p><strong>Response 2.</strong></p>
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
&quot;count&quot;: &quot;1&quot;,
&quot;startTimestamp&quot;: &quot;1611038000&quot;,
&quot;endTimestamp&quot;: &quot;1611039000&quot;
}
</pre></div>
</div>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&#169; 版权所有 2021, Peking University.
</p>
</div>
利用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 构建,使用了
<a href="https://github.com/readthedocs/sphinx_rtd_theme">主题</a>
<a href="https://readthedocs.org">Read the Docs</a>开发.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>