Program.html 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Program | @coral-xyz/anchor - v0.29.0</title><meta name="description" content="Documentation for @coral-xyz/anchor - v0.29.0"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@coral-xyz/anchor - v0.29.0</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../index.html">@coral-xyz/anchor - v0.29.0</a></li><li><a href="Program.html">Program</a></li></ul><h1>Class Program&lt;IDL&gt; </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
  2. <a href="#program" id="program" style="color: inherit; text-decoration: none;">
  3. <h2>Program</h2>
  4. </a>
  5. </div><div><p>Program provides the IDL deserialized client representation of an Anchor
  6. program.</p>
  7. <p>This API is the one stop shop for all things related to communicating with
  8. on-chain programs. Among other things, one can send transactions, fetch
  9. deserialized accounts, decode instruction data, subscribe to account
  10. changes, and listen to events.</p>
  11. <p>In addition to field accessors and methods, the object provides a set of
  12. dynamically generated properties, also known as namespaces, that
  13. map one-to-one to program methods and accounts. These namespaces generally
  14. can be used as follows:</p>
  15. <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
  16. <h2>Usage</h2>
  17. </a>
  18. <pre><code class="language-javascript"><span class="hl-0">program</span><span class="hl-1">.&lt;</span><span class="hl-0">namespace</span><span class="hl-1">&gt;.&lt;</span><span class="hl-0">program</span><span class="hl-1">-</span><span class="hl-0">specific</span><span class="hl-1">-</span><span class="hl-0">method</span><span class="hl-1">&gt;</span>
  19. </code></pre>
  20. <p>API specifics are namespace dependent. The examples used in the documentation
  21. below will refer to the two counter examples found
  22. <a href="https://github.com/coral-xyz/anchor#examples">here</a>.</p>
  23. </div></div></section><section class="tsd-panel tsd-type-parameters"><h3>Type Parameters</h3><ul class="tsd-type-parameters"><li><h4>IDL<span class="tsd-signature-symbol"> extends </span><a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a> = <a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a></h4></li></ul></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">Program</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter"><a href="Program.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#account" class="tsd-kind-icon">account</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#instruction" class="tsd-kind-icon">instruction</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#methods" class="tsd-kind-icon">methods</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#rpc" class="tsd-kind-icon">rpc</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#simulate" class="tsd-kind-icon">simulate</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#transaction" class="tsd-kind-icon">transaction</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#views" class="tsd-kind-icon">views</a></li></ul></section><section class="tsd-index-section "><h3>Accessors</h3><ul class="tsd-index-list"><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#coder" class="tsd-kind-icon">coder</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#idl" class="tsd-kind-icon">idl</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#programId" class="tsd-kind-icon">program<wbr/>Id</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#provider" class="tsd-kind-icon">provider</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#rawIdl" class="tsd-kind-icon">raw<wbr/>Idl</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><a href="Program.html#addEventListener" class="tsd-kind-icon">add<wbr/>Event<wbr/>Listener</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Program.html#removeEventListener" class="tsd-kind-icon">remove<wbr/>Event<wbr/>Listener</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><a href="Program.html#at" class="tsd-kind-icon">at</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><a href="Program.html#fetchIdl" class="tsd-kind-icon">fetch<wbr/>Idl</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link">constructor<a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter"><li class="tsd-signature tsd-kind-icon">new <wbr/>Program<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>idl<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span>, programId<span class="tsd-signature-symbol">: </span><a href="../index.html#Address" class="tsd-signature-type" data-tsd-kind="Type alias">Address</a>, provider<span class="tsd-signature-symbol">?: </span><a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a>, coder<span class="tsd-signature-symbol">?: </span><a href="../interfaces/Coder.html" class="tsd-signature-type" data-tsd-kind="Interface">Coder</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span>, getCustomResolver<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>instruction<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">IdlInstruction</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../index.html#CustomAccountResolver" class="tsd-signature-type" data-tsd-kind="Type alias">CustomAccountResolver</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="Program.html" class="tsd-signature-type" data-tsd-kind="Class">Program</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L282">packages/anchor/src/program/index.ts:282</a></li></ul></aside><h4 class="tsd-type-parameters-title">Type Parameters</h4><ul class="tsd-type-parameters"><li><h4>IDL<span class="tsd-signature-symbol"> extends </span><a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a> = <a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>idl: <span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
  24. <p>The interface definition.</p>
  25. </div></div></li><li><h5>programId: <a href="../index.html#Address" class="tsd-signature-type" data-tsd-kind="Type alias">Address</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
  26. <p>The on-chain address of the program.</p>
  27. </div></div></li><li><h5>provider: <a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a><span class="tsd-signature-symbol"> = ...</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
  28. <p>The network and wallet context to use. If not provided
  29. then uses <a href="../index.html#getProvider">getProvider</a>.</p>
  30. </div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> coder: <a href="../interfaces/Coder.html" class="tsd-signature-type" data-tsd-kind="Interface">Coder</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> getCustomResolver: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>instruction<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">IdlInstruction</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../index.html#CustomAccountResolver" class="tsd-signature-type" data-tsd-kind="Type alias">CustomAccountResolver</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
  31. <p>A function that returns a custom account resolver
  32. for the given instruction. This is useful for resolving
  33. public keys of missing accounts when building instructions</p>
  34. </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>instruction<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">IdlInstruction</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../index.html#CustomAccountResolver" class="tsd-signature-type" data-tsd-kind="Type alias">CustomAccountResolver</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>instruction: <span class="tsd-signature-type">IdlInstruction</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../index.html#CustomAccountResolver" class="tsd-signature-type" data-tsd-kind="Type alias">CustomAccountResolver</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <a href="Program.html" class="tsd-signature-type" data-tsd-kind="Class">Program</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="account" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagReadonly">Readonly</span> account<a href="#account" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">account<span class="tsd-signature-symbol">:</span> <a href="../index.html#AccountNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">AccountNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L113">packages/anchor/src/program/index.ts:113</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  35. <p>The namespace provides handles to an <a href="AccountClient.html">AccountClient</a> object for each
  36. account in the program.</p>
  37. </div><div>
  38. <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
  39. <h2>Usage</h2>
  40. </a>
  41. <pre><code class="language-javascript"><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">account</span><span class="hl-1">.&lt;</span><span class="hl-0">account</span><span class="hl-1">-</span><span class="hl-0">client</span><span class="hl-1">&gt;</span>
  42. </code></pre>
  43. <a href="#example" id="example" style="color: inherit; text-decoration: none;">
  44. <h2>Example</h2>
  45. </a>
  46. <p>To fetch a <code>Counter</code> account from the above example,</p>
  47. <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-1"> </span><span class="hl-3">counter</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">account</span><span class="hl-1">.</span><span class="hl-0">counter</span><span class="hl-1">.</span><span class="hl-5">fetch</span><span class="hl-1">(</span><span class="hl-0">address</span><span class="hl-1">);</span>
  48. </code></pre>
  49. <p>For the full API, see the <a href="AccountClient.html">AccountClient</a> reference.</p>
  50. </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="instruction" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagReadonly">Readonly</span> instruction<a href="#instruction" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">instruction<span class="tsd-signature-symbol">:</span> <a href="../index.html#InstructionNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">InstructionNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">AllInstructions</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L145">packages/anchor/src/program/index.ts:145</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  51. <p>The namespace provides functions to build <a href="web3.TransactionInstruction.html">TransactionInstruction</a>
  52. objects for each method of a program.</p>
  53. </div><div>
  54. <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
  55. <h2>Usage</h2>
  56. </a>
  57. <pre><code class="language-javascript"><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">instruction</span><span class="hl-1">.&lt;</span><span class="hl-0">method</span><span class="hl-1">&gt;(...</span><span class="hl-0">args</span><span class="hl-1">, </span><span class="hl-0">ctx</span><span class="hl-1">);</span>
  58. </code></pre>
  59. <a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
  60. <h2>Parameters</h2>
  61. </a>
  62. <ol>
  63. <li><code>args</code> - The positional arguments for the program. The type and number
  64. of these arguments depend on the program being used.</li>
  65. <li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
  66. Always the last parameter in the method call.</li>
  67. </ol>
  68. <a href="#example" id="example" style="color: inherit; text-decoration: none;">
  69. <h2>Example</h2>
  70. </a>
  71. <p>To create an instruction for the <code>increment</code> method above,</p>
  72. <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-1"> </span><span class="hl-3">tx</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">instruction</span><span class="hl-1">.</span><span class="hl-5">increment</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-0">accounts:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">counter</span><span class="hl-1">,</span><br/><span class="hl-1"> },</span><br/><span class="hl-1">});</span>
  73. </code></pre>
  74. </div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd></dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="methods" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagReadonly">Readonly</span> methods<a href="#methods" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">methods<span class="tsd-signature-symbol">:</span> <a href="../index.html#MethodsNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">MethodsNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">AllInstructions</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L220">packages/anchor/src/program/index.ts:220</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  75. <p>The namespace provides a builder API for all APIs on the program.
  76. This is an alternative to using namespace the other namespaces..</p>
  77. </div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="rpc" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagReadonly">Readonly</span> rpc<a href="#rpc" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">rpc<span class="tsd-signature-symbol">:</span> <a href="../index.html#RpcNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">RpcNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">AllInstructions</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L91">packages/anchor/src/program/index.ts:91</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  78. <p>Async methods to send signed transactions to <em>non</em>-state methods on the
  79. program, returning a <a href="../modules/web3.html#TransactionSignature">TransactionSignature</a>.</p>
  80. </div><div>
  81. <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
  82. <h2>Usage</h2>
  83. </a>
  84. <pre><code class="language-javascript"><span class="hl-0">rpc</span><span class="hl-1">.&lt;</span><span class="hl-0">method</span><span class="hl-1">&gt;(...</span><span class="hl-0">args</span><span class="hl-1">, </span><span class="hl-0">ctx</span><span class="hl-1">);</span>
  85. </code></pre>
  86. <a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
  87. <h2>Parameters</h2>
  88. </a>
  89. <ol>
  90. <li><code>args</code> - The positional arguments for the program. The type and number
  91. of these arguments depend on the program being used.</li>
  92. <li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
  93. Always the last parameter in the method call.</li>
  94. </ol>
  95. <a href="#example" id="example" style="color: inherit; text-decoration: none;">
  96. <h2>Example</h2>
  97. </a>
  98. <p>To send a transaction invoking the <code>increment</code> method above,</p>
  99. <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-1"> </span><span class="hl-3">txSignature</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">rpc</span><span class="hl-1">.</span><span class="hl-5">increment</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-0">accounts:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">counter</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-0">authority</span><span class="hl-1">,</span><br/><span class="hl-1"> },</span><br/><span class="hl-1">});</span>
  100. </code></pre>
  101. </div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>Use program.methods.<method>(...args).rpc() instead</p>
  102. </dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="simulate" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagReadonly">Readonly</span> simulate<a href="#simulate" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">simulate<span class="tsd-signature-symbol">:</span> <a href="../index.html#SimulateNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">SimulateNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">AllInstructions</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L214">packages/anchor/src/program/index.ts:214</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  103. <p>The namespace provides functions to simulate transactions for each method
  104. of a program, returning a list of deserialized events <em>and</em> raw program
  105. logs.</p>
  106. </div><div><p>One can use this to read data calculated from a program on chain, by
  107. emitting an event in the program and reading the emitted event client side
  108. via the <code>simulate</code> namespace.</p>
  109. <a href="#simulate" id="simulate" style="color: inherit; text-decoration: none;">
  110. <h2>simulate</h2>
  111. </a>
  112. <pre><code class="language-javascript"><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">simulate</span><span class="hl-1">.&lt;</span><span class="hl-0">method</span><span class="hl-1">&gt;(...</span><span class="hl-0">args</span><span class="hl-1">, </span><span class="hl-0">ctx</span><span class="hl-1">);</span>
  113. </code></pre>
  114. <a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
  115. <h2>Parameters</h2>
  116. </a>
  117. <ol>
  118. <li><code>args</code> - The positional arguments for the program. The type and number
  119. of these arguments depend on the program being used.</li>
  120. <li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
  121. Always the last parameter in the method call.</li>
  122. </ol>
  123. <a href="#example" id="example" style="color: inherit; text-decoration: none;">
  124. <h2>Example</h2>
  125. </a>
  126. <p>To simulate the <code>increment</code> method above,</p>
  127. <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-1"> </span><span class="hl-3">events</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">simulate</span><span class="hl-1">.</span><span class="hl-5">increment</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-0">accounts:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">counter</span><span class="hl-1">,</span><br/><span class="hl-1"> },</span><br/><span class="hl-1">});</span>
  128. </code></pre>
  129. </div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd></dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="transaction" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagReadonly">Readonly</span> transaction<a href="#transaction" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">transaction<span class="tsd-signature-symbol">:</span> <a href="../index.html#TransactionNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">TransactionNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">AllInstructions</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L177">packages/anchor/src/program/index.ts:177</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  130. <p>The namespace provides functions to build <a href="web3.Transaction.html">Transaction</a> objects for each
  131. method of a program.</p>
  132. </div><div>
  133. <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
  134. <h2>Usage</h2>
  135. </a>
  136. <pre><code class="language-javascript"><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">transaction</span><span class="hl-1">.&lt;</span><span class="hl-0">method</span><span class="hl-1">&gt;(...</span><span class="hl-0">args</span><span class="hl-1">, </span><span class="hl-0">ctx</span><span class="hl-1">);</span>
  137. </code></pre>
  138. <a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
  139. <h2>Parameters</h2>
  140. </a>
  141. <ol>
  142. <li><code>args</code> - The positional arguments for the program. The type and number
  143. of these arguments depend on the program being used.</li>
  144. <li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
  145. Always the last parameter in the method call.</li>
  146. </ol>
  147. <a href="#example" id="example" style="color: inherit; text-decoration: none;">
  148. <h2>Example</h2>
  149. </a>
  150. <p>To create an instruction for the <code>increment</code> method above,</p>
  151. <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-1"> </span><span class="hl-3">tx</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">program</span><span class="hl-1">.</span><span class="hl-0">transaction</span><span class="hl-1">.</span><span class="hl-5">increment</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-0">accounts:</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">counter</span><span class="hl-1">,</span><br/><span class="hl-1"> },</span><br/><span class="hl-1">});</span>
  152. </code></pre>
  153. </div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd></dd></dl></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="views" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagOptional">Optional</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> views<a href="#views" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><div class="tsd-signature tsd-kind-icon">views<span class="tsd-signature-symbol">?:</span> <a href="../index.html#ViewNamespace" class="tsd-signature-type" data-tsd-kind="Type alias">ViewNamespace</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">AllInstructions</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L222">packages/anchor/src/program/index.ts:222</a></li></ul></aside></section></section><section class="tsd-panel-group tsd-member-group "><h2>Accessors</h2><section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"><a id="coder" class="tsd-anchor"></a><h3 class="tsd-anchor-link">coder<a href="#coder" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> coder<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/Coder.html" class="tsd-signature-type" data-tsd-kind="Interface">Coder</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L255">packages/anchor/src/program/index.ts:255</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  154. <p>Coder for serializing requests.</p>
  155. </div></div><h4 class="tsd-returns-title">Returns <a href="../interfaces/Coder.html" class="tsd-signature-type" data-tsd-kind="Interface">Coder</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"><a id="idl" class="tsd-anchor"></a><h3 class="tsd-anchor-link">idl<a href="#idl" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> idl<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L237">packages/anchor/src/program/index.ts:237</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  156. <p>IDL in camelCase format to work in TypeScript.</p>
  157. </div><div><p>See <a href="Program.html#rawIdl">rawIdl</a> field if you need the original IDL.</p>
  158. </div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"><a id="programId" class="tsd-anchor"></a><h3 class="tsd-anchor-link">program<wbr/>Id<a href="#programId" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> programId<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="web3.PublicKey.html" class="tsd-signature-type" data-tsd-kind="Class">PublicKey</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L227">packages/anchor/src/program/index.ts:227</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  159. <p>Address of the program.</p>
  160. </div></div><h4 class="tsd-returns-title">Returns <a href="web3.PublicKey.html" class="tsd-signature-type" data-tsd-kind="Class">PublicKey</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"><a id="provider" class="tsd-anchor"></a><h3 class="tsd-anchor-link">provider<a href="#provider" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> provider<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L263">packages/anchor/src/program/index.ts:263</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  161. <p>Wallet and network provider.</p>
  162. </div></div><h4 class="tsd-returns-title">Returns <a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-get-signature tsd-parent-kind-class"><a id="rawIdl" class="tsd-anchor"></a><h3 class="tsd-anchor-link">raw<wbr/>Idl<a href="#rawIdl" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-get-signature tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">get</span> rawIdl<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L247">packages/anchor/src/program/index.ts:247</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  163. <p>Raw IDL i.e. the original IDL without camelCase conversion.</p>
  164. </div><div><p>See <a href="Program.html#idl">idl</a> field if you need the camelCased version of the IDL.</p>
  165. </div></div><h4 class="tsd-returns-title">Returns <a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><a id="addEventListener" class="tsd-anchor"></a><h3 class="tsd-anchor-link">add<wbr/>Event<wbr/>Listener<a href="#addEventListener" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><li class="tsd-signature tsd-kind-icon">add<wbr/>Event<wbr/>Listener<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>eventName<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">string</span>, callback<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><a href="../index.html#IdlEvents" class="tsd-signature-type" data-tsd-kind="Type alias">IdlEvents</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol">]</span>, slot<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, signature<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L378">packages/anchor/src/program/index.ts:378</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  166. <p>Invokes the given callback every time the given event is emitted.</p>
  167. </div></div><h4 class="tsd-type-parameters-title">Type Parameters</h4><ul class="tsd-type-parameters"><li><h4>E<span class="tsd-signature-symbol"> extends </span><span class="tsd-signature-type">string</span></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>eventName: <span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
  168. <p>The PascalCase name of the event, provided by the IDL.</p>
  169. </div></div></li><li><h5>callback: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><a href="../index.html#IdlEvents" class="tsd-signature-type" data-tsd-kind="Type alias">IdlEvents</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol">]</span>, slot<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, signature<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
  170. <p>The function to invoke whenever the event is emitted from
  171. program logs.</p>
  172. </div></div><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><a href="../index.html#IdlEvents" class="tsd-signature-type" data-tsd-kind="Type alias">IdlEvents</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol">]</span>, slot<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, signature<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>event: <a href="../index.html#IdlEvents" class="tsd-signature-type" data-tsd-kind="Type alias">IdlEvents</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">E</span><span class="tsd-signature-symbol">]</span></h5></li><li><h5>slot: <span class="tsd-signature-type">number</span></h5></li><li><h5>signature: <span class="tsd-signature-type">string</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="removeEventListener" class="tsd-anchor"></a><h3 class="tsd-anchor-link">remove<wbr/>Event<wbr/>Listener<a href="#removeEventListener" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">remove<wbr/>Event<wbr/>Listener<span class="tsd-signature-symbol">(</span>listener<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L392">packages/anchor/src/program/index.ts:392</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  173. <p>Unsubscribes from the given eventName.</p>
  174. </div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>listener: <span class="tsd-signature-type">number</span></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><a id="at" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> at<a href="#at" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><li class="tsd-signature tsd-kind-icon">at<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><a href="../index.html#Address" class="tsd-signature-type" data-tsd-kind="Type alias">Address</a>, provider<span class="tsd-signature-symbol">?: </span><a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="Program.html" class="tsd-signature-type" data-tsd-kind="Class">Program</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L330">packages/anchor/src/program/index.ts:330</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  175. <p>Generates a Program client by fetching the IDL from the network.</p>
  176. </div><div><p>In order to use this method, an IDL must have been previously initialized
  177. via the anchor CLI&#39;s <code>anchor idl init</code> command.</p>
  178. </div></div><h4 class="tsd-type-parameters-title">Type Parameters</h4><ul class="tsd-type-parameters"><li><h4>IDL<span class="tsd-signature-symbol"> extends </span><a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a> = <a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>address: <a href="../index.html#Address" class="tsd-signature-type" data-tsd-kind="Type alias">Address</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> provider: <a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
  179. <p>The network and wallet context.</p>
  180. </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="Program.html" class="tsd-signature-type" data-tsd-kind="Class">Program</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><a id="fetchIdl" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> fetch<wbr/>Idl<a href="#fetchIdl" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><li class="tsd-signature tsd-kind-icon">fetch<wbr/>Idl<span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><a href="../index.html#Address" class="tsd-signature-type" data-tsd-kind="Type alias">Address</a>, provider<span class="tsd-signature-symbol">?: </span><a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/acheroncrypto/anchor/blob/d9a9f193/ts/packages/anchor/src/program/index.ts#L353">packages/anchor/src/program/index.ts:353</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
  181. <p>Fetches an idl from the blockchain.</p>
  182. </div><div><p>In order to use this method, an IDL must have been previously initialized
  183. via the anchor CLI&#39;s <code>anchor idl init</code> command.</p>
  184. </div></div><h4 class="tsd-type-parameters-title">Type Parameters</h4><ul class="tsd-type-parameters"><li><h4>IDL<span class="tsd-signature-symbol"> extends </span><a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a> = <a href="../index.html#Idl" class="tsd-signature-type" data-tsd-kind="Type alias">Idl</a></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>address: <a href="../index.html#Address" class="tsd-signature-type" data-tsd-kind="Type alias">Address</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> provider: <a href="../interfaces/Provider.html" class="tsd-signature-type" data-tsd-kind="Interface">Provider</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
  185. <p>The network and wallet context.</p>
  186. </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">&gt;</span></h4></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../index.html">Exports</a></li><li class="label tsd-is-external"><span>Internals</span></li><li class=" tsd-kind-namespace"><a href="../modules/utils.html">utils</a></li><li class="label tsd-is-external"><span>Externals</span></li><li class=" tsd-kind-namespace tsd-is-external"><a href="../modules/BN.html">BN</a></li><li class=" tsd-kind-namespace tsd-is-external"><a href="../modules/web3.html">web3</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-class tsd-has-type-parameter"><a href="Program.html" class="tsd-kind-icon">Program</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class tsd-has-type-parameter"><a href="Program.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#account" class="tsd-kind-icon">account</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#instruction" class="tsd-kind-icon">instruction</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#methods" class="tsd-kind-icon">methods</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#rpc" class="tsd-kind-icon">rpc</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#simulate" class="tsd-kind-icon">simulate</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#transaction" class="tsd-kind-icon">transaction</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="Program.html#views" class="tsd-kind-icon">views</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#coder" class="tsd-kind-icon">coder</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#idl" class="tsd-kind-icon">idl</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#programId" class="tsd-kind-icon">program<wbr/>Id</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#provider" class="tsd-kind-icon">provider</a></li><li class="tsd-kind-get-signature tsd-parent-kind-class"><a href="Program.html#rawIdl" class="tsd-kind-icon">raw<wbr/>Idl</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><a href="Program.html#addEventListener" class="tsd-kind-icon">add<wbr/>Event<wbr/>Listener</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="Program.html#removeEventListener" class="tsd-kind-icon">remove<wbr/>Event<wbr/>Listener</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><a href="Program.html#at" class="tsd-kind-icon">at</a></li><li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static"><a href="Program.html#fetchIdl" class="tsd-kind-icon">fetch<wbr/>Idl</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>