anchor/ts/classes/Program.html

194 lines
57 KiB
HTML

<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Program | @project-serum/anchor - v0.25.0</title><meta name="description" content="Documentation for @project-serum/anchor - v0.25.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">@project-serum/anchor - v0.25.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">@project-serum/anchor - v0.25.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">
<a href="#program" id="program" style="color: inherit; text-decoration: none;">
<h2>Program</h2>
</a>
</div><div><p>Program provides the IDL deserialized client representation of an Anchor
program.</p>
<p>This API is the one stop shop for all things related to communicating with
on-chain programs. Among other things, one can send transactions, fetch
deserialized accounts, decode instruction data, subscribe to account
changes, and listen to events.</p>
<p>In addition to field accessors and methods, the object provides a set of
dynamically generated properties, also known as namespaces, that
map one-to-one to program methods and accounts. These namespaces generally
can be used as follows:</p>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<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>
</code></pre>
<p>API specifics are namespace dependent. The examples used in the documentation
below will refer to the two counter examples found
<a href="https://github.com/coral-xyz/anchor#examples">here</a>.</p>
</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">: </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#state" class="tsd-kind-icon">state</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></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class"><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><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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L267">src/program/index.ts:267</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">: </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">
<p>The interface definition.</p>
</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">
<p>The on-chain address of the program.</p>
</div></div></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">
<p>The network and wallet context to use. If not provided
then uses <a href="../index.html#getProvider">getProvider</a>.</p>
</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></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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L106">src/program/index.ts:106</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>The namespace provides handles to an <a href="AccountClient.html">AccountClient</a> object for each
account in the program.</p>
</div><div>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<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>
</code></pre>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h2>Example</h2>
</a>
<p>To fetch a <code>Counter</code> account from the above example,</p>
<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>
</code></pre>
<p>For the full API, see the <a href="AccountClient.html">AccountClient</a> reference.</p>
</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" data-tsd-kind="Type parameter">IDL</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">&quot;instructions&quot;</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">&gt;</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L138">src/program/index.ts:138</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>The namespace provides functions to build <a href="web3.TransactionInstruction.html">TransactionInstruction</a>
objects for each method of a program.</p>
</div><div>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<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>
</code></pre>
<a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
<h2>Parameters</h2>
</a>
<ol>
<li><code>args</code> - The positional arguments for the program. The type and number
of these arguments depend on the program being used.</li>
<li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
Always the last parameter in the method call.</li>
</ol>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h2>Example</h2>
</a>
<p>To create an instruction for the <code>increment</code> method above,</p>
<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>
</code></pre>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L220">src/program/index.ts:220</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>The namespace provides a builder API for all APIs on the program.
This is an alternative to using namespace the other namespaces..</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L84">src/program/index.ts:84</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Async methods to send signed transactions to <em>non</em>-state methods on the
program, returning a <a href="../modules/web3.html#TransactionSignature">TransactionSignature</a>.</p>
</div><div>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<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>
</code></pre>
<a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
<h2>Parameters</h2>
</a>
<ol>
<li><code>args</code> - The positional arguments for the program. The type and number
of these arguments depend on the program being used.</li>
<li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
Always the last parameter in the method call.</li>
</ol>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h2>Example</h2>
</a>
<p>To send a transaction invoking the <code>increment</code> method above,</p>
<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>
</code></pre>
</div><dl class="tsd-comment-tags"><dt>deprecated</dt><dd><p>Use program.methods.<method>(...args).rpc() instead</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L207">src/program/index.ts:207</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>The namespace provides functions to simulate transactions for each method
of a program, returning a list of deserialized events <em>and</em> raw program
logs.</p>
</div><div><p>One can use this to read data calculated from a program on chain, by
emitting an event in the program and reading the emitted event client side
via the <code>simulate</code> namespace.</p>
<a href="#simulate" id="simulate" style="color: inherit; text-decoration: none;">
<h2>simulate</h2>
</a>
<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>
</code></pre>
<a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
<h2>Parameters</h2>
</a>
<ol>
<li><code>args</code> - The positional arguments for the program. The type and number
of these arguments depend on the program being used.</li>
<li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
Always the last parameter in the method call.</li>
</ol>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h2>Example</h2>
</a>
<p>To simulate the <code>increment</code> method above,</p>
<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>
</code></pre>
</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="state" 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> state<a href="#state" 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">state<span class="tsd-signature-symbol">?:</span> <a href="StateClient.html" class="tsd-signature-type" data-tsd-kind="Class">StateClient</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L214">src/program/index.ts:214</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>A client for the program state. Similar to the base <a href="Program.html">Program</a> client,
one can use this to send transactions and read accounts for the state
abstraction.</p>
</div></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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L170">src/program/index.ts:170</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>The namespace provides functions to build <a href="web3.Transaction.html">Transaction</a> objects for each
method of a program.</p>
</div><div>
<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
<h2>Usage</h2>
</a>
<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>
</code></pre>
<a href="#parameters" id="parameters" style="color: inherit; text-decoration: none;">
<h2>Parameters</h2>
</a>
<ol>
<li><code>args</code> - The positional arguments for the program. The type and number
of these arguments depend on the program being used.</li>
<li><code>ctx</code> - <a href="../modules/web3.html#Context">Context</a> non-argument parameters to pass to the method.
Always the last parameter in the method call.</li>
</ol>
<a href="#example" id="example" style="color: inherit; text-decoration: none;">
<h2>Example</h2>
</a>
<p>To create an instruction for the <code>increment</code> method above,</p>
<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>
</code></pre>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L222">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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L243">src/program/index.ts:243</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Coder for serializing requests.</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L235">src/program/index.ts:235</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>IDL defining the program&#39;s interface.</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L227">src/program/index.ts:227</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Address of the program.</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L251">src/program/index.ts:251</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Wallet and network provider.</p>
</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><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><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"><li class="tsd-signature tsd-kind-icon">add<wbr/>Event<wbr/>Listener<span class="tsd-signature-symbol">(</span>eventName<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, callback<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</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-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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L364">src/program/index.ts:364</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Invokes the given callback every time the given event is emitted.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>eventName: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The PascalCase name of the event, provided by the IDL.</p>
</div></div></li><li><h5>callback: <span class="tsd-signature-symbol">(</span>event<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</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></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>The function to invoke whenever the event is emitted from
program logs.</p>
</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><span class="tsd-signature-type">any</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: <span class="tsd-signature-type">any</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L374">src/program/index.ts:374</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Unsubscribes from the given eventName.</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L316">src/program/index.ts:316</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Generates a Program client by fetching the IDL from the network.</p>
</div><div><p>In order to use this method, an IDL must have been previously initialized
via the anchor CLI&#39;s <code>anchor idl init</code> command.</p>
</div></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>IDL<span class="tsd-signature-symbol">: </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">
<p>The network and wallet context.</p>
</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/project-serum/anchor/blob/6baed77e/ts/src/program/index.ts#L339">src/program/index.ts:339</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Fetches an idl from the blockchain.</p>
</div><div><p>In order to use this method, an IDL must have been previously initialized
via the anchor CLI&#39;s <code>anchor idl init</code> command.</p>
</div></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>IDL<span class="tsd-signature-symbol">: </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">
<p>The network and wallet context.</p>
</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#state" class="tsd-kind-icon">state</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-method tsd-parent-kind-class"><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-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><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited 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-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>