[CI Skip] 0.41.10
This commit is contained in:
@@ -2155,16 +2155,12 @@
|
||||
  <span class="sunlight-comment">// Instantiate the API</span>
|
||||
  <span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-ident">await</span> <span class="sunlight-ident">ApiPromise</span><span class="sunlight-operator">.</span><span class="sunlight-ident">create</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
|
||||
  <span class="sunlight-comment">// Retrieve the nonce for Alice, to be used to sign the transaction</span>
|
||||
  <span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">aliceNonce</span> <span class="sunlight-operator">=</span> <span class="sunlight-ident">await</span> <span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">query</span><span class="sunlight-operator">.</span><span class="sunlight-ident">system</span><span class="sunlight-operator">.</span><span class="sunlight-ident">accountNonce</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">alice</span><span class="sunlight-operator">.</span><span class="sunlight-ident">address</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
|
||||
  <span class="sunlight-comment">// Create a extrinsic, transferring 12345 units to Bob. We can also create,</span>
|
||||
  <span class="sunlight-comment">// sign and send in one operation (as per the samples in the Api documentation),</span>
|
||||
  <span class="sunlight-comment">// here we split it out for the sake of readability</span>
|
||||
  <span class="sunlight-comment">// Create a extrinsic, transferring 12345 units to Bob</span>
|
||||
  <span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">transfer</span> <span class="sunlight-operator">=</span> <span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">tx</span><span class="sunlight-operator">.</span><span class="sunlight-ident">balances</span><span class="sunlight-operator">.</span><span class="sunlight-ident">transfer</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">BOB_ADDR</span><span class="sunlight-punctuation">,</span> <span class="sunlight-number">12345</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
|
||||
  <span class="sunlight-comment">// Sign and send the transaction using our account. Send the transaction and retrieve the resulting Hash</span>
|
||||
  <span class="sunlight-comment">// Sign and send the transaction using our account</span>
|
||||
  <span class="sunlight-ident">transfer</span><span class="sunlight-operator">.</span><span class="sunlight-ident">signAndSend</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">alice</span><span class="sunlight-punctuation">,</span> <span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">{</span> <span class="sunlight-ident">status</span><span class="sunlight-punctuation">,</span> <span class="sunlight-ident">type</span> <span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span> <span class="sunlight-operator">=</span><span class="sunlight-operator">></span> <span class="sunlight-punctuation">{</span>
|
||||
    <span class="sunlight-comment">// retrieve the hash once we are finalised</span>
|
||||
    <span class="sunlight-keyword">if</span> <span class="sunlight-punctuation">(</span><span class="sunlight-ident">type</span> <span class="sunlight-operator">===</span> <span class="sunlight-string">'Finalised'</span><span class="sunlight-punctuation">)</span> <span class="sunlight-punctuation">{</span>
|
||||
      <span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-ident">Successful</span> <span class="sunlight-ident">transfer</span> <span class="sunlight-ident">of</span> <span class="sunlight-number">12345</span> <span class="sunlight-ident">from</span> <span class="sunlight-ident">Alice</span> <span class="sunlight-ident">to</span> <span class="sunlight-ident">Bob</span> <span class="sunlight-keyword">with</span> <span class="sunlight-ident">hash</span> <span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">status</span><span class="sunlight-operator">.</span><span class="sunlight-ident">asFinalised</span><span class="sunlight-operator">.</span><span class="sunlight-ident">toHex</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
    <span class="sunlight-punctuation">}</span> <span class="sunlight-keyword">else</span> <span class="sunlight-punctuation">{</span>
|
||||
@@ -2218,7 +2214,7 @@
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Make a transfer","level":"3.1.6","depth":2,"next":{"title":"Display system events","level":"3.1.7","depth":2,"path":"examples/promise/08_system_events/README.md","ref":"examples/promise/08_system_events/README.md","articles":[]},"previous":{"title":"Read chain state","level":"3.1.5","depth":2,"path":"examples/promise/05_read_storage/README.md","ref":"examples/promise/05_read_storage/README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","insert-logo-link","mermaid-gb3","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css"},"pluginsConfig":{"insert-logo-link":{"src":"/api/logo.png","url":"https://polkadot.js.org"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"examples/promise/06_make_transfer/README.md","mtime":"2019-01-29T16:10:41.317Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-01-29T16:14:59.334Z"},"basePath":"../../..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Make a transfer","level":"3.1.6","depth":2,"next":{"title":"Display system events","level":"3.1.7","depth":2,"path":"examples/promise/08_system_events/README.md","ref":"examples/promise/08_system_events/README.md","articles":[]},"previous":{"title":"Read chain state","level":"3.1.5","depth":2,"path":"examples/promise/05_read_storage/README.md","ref":"examples/promise/05_read_storage/README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","insert-logo-link","mermaid-gb3","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css"},"pluginsConfig":{"insert-logo-link":{"src":"/api/logo.png","url":"https://polkadot.js.org"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"examples/promise/06_make_transfer/README.md","mtime":"2019-01-29T18:48:21.724Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-01-29T18:52:31.630Z"},"basePath":"../../..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user