commands.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>Commands | ⚓ Anchor</title>
  7. <meta name="generator" content="VuePress 1.8.2">
  8. <link rel="icon" href="data:image/svg+xml,&lt;svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22&gt;&lt;text y=%22.9em%22 font-size=%2290%22&gt;⚓ &lt;/text&gt;&lt;/svg&gt;">
  9. <meta name="description" content="">
  10. <meta name="theme-color" content="#3eaf7c">
  11. <meta name="apple-mobile-web-app-capable" content="yes">
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  13. <link rel="preload" href="/anchor/assets/css/0.styles.21b321ec.css" as="style"><link rel="preload" href="/anchor/assets/js/app.b2f13cd7.js" as="script"><link rel="preload" href="/anchor/assets/js/2.90291299.js" as="script"><link rel="preload" href="/anchor/assets/js/10.99d917b5.js" as="script"><link rel="prefetch" href="/anchor/assets/js/11.45e25cc5.js"><link rel="prefetch" href="/anchor/assets/js/12.d30544e0.js"><link rel="prefetch" href="/anchor/assets/js/13.7bb3490d.js"><link rel="prefetch" href="/anchor/assets/js/14.258e35e3.js"><link rel="prefetch" href="/anchor/assets/js/15.243176ff.js"><link rel="prefetch" href="/anchor/assets/js/16.b6cb9e25.js"><link rel="prefetch" href="/anchor/assets/js/17.29eac49f.js"><link rel="prefetch" href="/anchor/assets/js/18.db5dc2ee.js"><link rel="prefetch" href="/anchor/assets/js/19.b9ce785c.js"><link rel="prefetch" href="/anchor/assets/js/20.50564768.js"><link rel="prefetch" href="/anchor/assets/js/21.b31f2925.js"><link rel="prefetch" href="/anchor/assets/js/3.397fd877.js"><link rel="prefetch" href="/anchor/assets/js/4.f90252b7.js"><link rel="prefetch" href="/anchor/assets/js/5.47891694.js"><link rel="prefetch" href="/anchor/assets/js/6.493f79e9.js"><link rel="prefetch" href="/anchor/assets/js/7.32936426.js"><link rel="prefetch" href="/anchor/assets/js/8.9fc829e7.js"><link rel="prefetch" href="/anchor/assets/js/9.525a5964.js">
  14. <link rel="stylesheet" href="/anchor/assets/css/0.styles.21b321ec.css">
  15. </head>
  16. <body>
  17. <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/anchor/" class="home-link router-link-active"><!----> <span class="site-name">⚓ Anchor</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://book.anchor-lang.com" target="_blank" rel="noopener noreferrer" class="nav-link external">
  18. The Anchor Book
  19. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://docs.rs/anchor-lang/latest/anchor_lang/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  20. Rust
  21. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://project-serum.github.io/anchor/ts/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  22. TypeScript
  23. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://github.com/project-serum/anchor" target="_blank" rel="noopener noreferrer" class="nav-link external">
  24. GitHub
  25. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="https://book.anchor-lang.com" target="_blank" rel="noopener noreferrer" class="nav-link external">
  26. The Anchor Book
  27. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://docs.rs/anchor-lang/latest/anchor_lang/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  28. Rust
  29. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://project-serum.github.io/anchor/ts/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  30. TypeScript
  31. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://github.com/project-serum/anchor" target="_blank" rel="noopener noreferrer" class="nav-link external">
  32. GitHub
  33. <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Getting Started</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/anchor/getting-started/introduction.html" class="sidebar-link">Introduction</a></li><li><a href="/anchor/getting-started/installation.html" class="sidebar-link">Installing Dependencies</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Teams</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/anchor/getting-started/projects.html" class="sidebar-link">Projects</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Tutorials</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/anchor/tutorials/tutorial-0.html" class="sidebar-link">A Minimal Example</a></li><li><a href="/anchor/tutorials/tutorial-1.html" class="sidebar-link">Arguments and Accounts</a></li><li><a href="/anchor/tutorials/tutorial-2.html" class="sidebar-link">Account Constraints and Access Control</a></li><li><a href="/anchor/tutorials/tutorial-3.html" class="sidebar-link">Cross Program Invocations (CPI)</a></li><li><a href="/anchor/tutorials/tutorial-4.html" class="sidebar-link">Errors</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>CLI</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/anchor/cli/commands.html" aria-current="page" class="active sidebar-link">Commands</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#build" class="sidebar-link">Build</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#cluster" class="sidebar-link">Cluster</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#cluster-list" class="sidebar-link">Cluster list</a></li></ul></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#deploy" class="sidebar-link">Deploy</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#expand" class="sidebar-link">Expand</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#idl" class="sidebar-link">Idl</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#idl-init" class="sidebar-link">Idl Init</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#idl-fetch" class="sidebar-link">Idl Fetch</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#idl-authority" class="sidebar-link">Idl Authority</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#idl-erase-authority" class="sidebar-link">Idl Erase Authority</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#idl-upgrade" class="sidebar-link">Idl Upgrade</a></li></ul></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#init" class="sidebar-link">Init</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#migrate" class="sidebar-link">Migrate</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#new" class="sidebar-link">New</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#test" class="sidebar-link">Test</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#upgrade" class="sidebar-link">Upgrade</a></li><li class="sidebar-sub-header"><a href="/anchor/cli/commands.html#verify" class="sidebar-link">Verify</a></li></ul></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Source Verification</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/anchor/getting-started/verification.html" class="sidebar-link">Verifiable Builds</a></li><li><a href="/anchor/getting-started/publishing.html" class="sidebar-link">Publishing Source</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="commands"><a href="#commands" class="header-anchor">#</a> Commands</h1> <p>A CLI is provided to support building and managing an Anchor workspace.
  34. For a comprehensive list of commands and options, run <code>anchor -h</code> on any
  35. of the following subcommands.</p> <div class="language- extra-class"><pre class="language-text"><code>anchor-cli
  36. USAGE:
  37. anchor &lt;SUBCOMMAND&gt;
  38. FLAGS:
  39. -h, --help Prints help information
  40. -V, --version Prints version information
  41. SUBCOMMANDS:
  42. build Builds the workspace
  43. cluster Cluster commands
  44. deploy Deploys each program in the workspace
  45. expand Expands the macros of a program or the workspace
  46. help Prints this message or the help of the given subcommand(s)
  47. idl Commands for interacting with interface definitions
  48. init Initializes a workspace
  49. migrate Runs the deploy migration script
  50. new Creates a new program
  51. test Runs integration tests against a localnetwork
  52. upgrade Upgrades a single program. The configured wallet must be the upgrade authority
  53. verify Verifies the on-chain bytecode matches the locally compiled artifact. Run this
  54. command inside a program subdirectory, i.e., in the dir containing the program's
  55. Cargo.toml
  56. </code></pre></div><h2 id="build"><a href="#build" class="header-anchor">#</a> Build</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor build
  57. </code></pre></div><p>Builds programs in the workspace targeting Solana's BPF runtime and emitting IDLs in the <code>target/idl</code> directory.</p> <div class="language- extra-class"><pre class="language-text"><code>anchor build --verifiable
  58. </code></pre></div><p>Runs the build inside a docker image so that the output binary is deterministic (assuming a Cargo.lock file is used). This command must be run from within a single crate subdirectory within the workspace. For example, <code>programs/&lt;my-program&gt;/</code>.</p> <h2 id="cluster"><a href="#cluster" class="header-anchor">#</a> Cluster</h2> <h3 id="cluster-list"><a href="#cluster-list" class="header-anchor">#</a> Cluster list</h3> <div class="language- extra-class"><pre class="language-text"><code>anchor cluster list
  59. </code></pre></div><p>This lists cluster endpoints:</p> <div class="language- extra-class"><pre class="language-text"><code>Cluster Endpoints:
  60. * Mainnet - https://solana-api.projectserum.com
  61. * Mainnet - https://api.mainnet-beta.solana.com
  62. * Devnet - https://api.devnet.solana.com
  63. * Testnet - https://api.testnet.solana.com
  64. </code></pre></div><h2 id="deploy"><a href="#deploy" class="header-anchor">#</a> Deploy</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor deploy
  65. </code></pre></div><p>Deploys all programs in the workspace to the configured cluster.</p> <div class="custom-block tip"><p class="custom-block-title">Note</p> <p>This is different from the <code>solana program deploy</code> command, because everytime it's run
  66. it will generate a <em>new</em> program address.</p></div> <h2 id="expand"><a href="#expand" class="header-anchor">#</a> Expand</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor expand
  67. </code></pre></div><p>If run inside a program folder, expands the macros of the program.</p> <p>If run in the workspace but outside a program folder, expands the macros of the workspace.</p> <p>If run with the <code>--program-name</code> option, expand only the given program.</p> <h2 id="idl"><a href="#idl" class="header-anchor">#</a> Idl</h2> <p>The <code>idl</code> subcommand provides commands for interacting with interface definition files.
  68. It's recommended to use these commands to store an IDL on chain, at a deterministic
  69. address, as a function of nothing but the the program's ID. This
  70. allows us to generate clients for a program using nothing but the program ID.</p> <h3 id="idl-init"><a href="#idl-init" class="header-anchor">#</a> Idl Init</h3> <div class="language- extra-class"><pre class="language-text"><code>anchor idl init -f &lt;target/idl/program.json&gt; &lt;program-id&gt;
  71. </code></pre></div><p>Creates an idl account, writing the given <code>&lt;target/idl/program.json&gt;</code> file into a program owned account. By default, the size of the account is double the size of the IDL,
  72. allowing room for growth in case the idl needs to be upgraded in the future.</p> <h3 id="idl-fetch"><a href="#idl-fetch" class="header-anchor">#</a> Idl Fetch</h3> <div class="language- extra-class"><pre class="language-text"><code>anchor idl fetch -o &lt;out-file.json&gt; &lt;program-id&gt;
  73. </code></pre></div><p>Fetches an IDL from the configured blockchain. For example, make sure
  74. your <code>Anchor.toml</code> is pointing to the <code>mainnet</code> cluster and run</p> <div class="language- extra-class"><pre class="language-text"><code>anchor idl fetch GrAkKfEpTKQuVHG2Y97Y2FF4i7y7Q5AHLK94JBy7Y5yv
  75. </code></pre></div><h3 id="idl-authority"><a href="#idl-authority" class="header-anchor">#</a> Idl Authority</h3> <div class="language- extra-class"><pre class="language-text"><code>anchor idl authority &lt;program-id&gt;
  76. </code></pre></div><p>Outputs the IDL account's authority. This is the wallet that has the ability to
  77. update the IDL.</p> <h3 id="idl-erase-authority"><a href="#idl-erase-authority" class="header-anchor">#</a> Idl Erase Authority</h3> <div class="language- extra-class"><pre class="language-text"><code>anchor idl erase-authority -p &lt;program-id&gt;
  78. </code></pre></div><p>Erases the IDL account's authority so that upgrades can no longer occur. The
  79. configured wallet must be the current authority.</p> <h3 id="idl-upgrade"><a href="#idl-upgrade" class="header-anchor">#</a> Idl Upgrade</h3> <div class="language- extra-class"><pre class="language-text"><code>anchor idl upgrade &lt;program-id&gt; -f &lt;target/idl/program.json&gt;
  80. </code></pre></div><p>Upgrades the IDL file on chain to the new <code>target/idl/program.json</code> idl.
  81. The configured wallet must be the current authority.</p> <div class="language- extra-class"><pre class="language-text"><code>anchor idl set-authority -n &lt;new-authority&gt; -p &lt;program-id&gt;
  82. </code></pre></div><p>Sets a new authority on the IDL account. Both the <code>new-authority</code> and <code>program-id</code>
  83. must be encoded in base 58.</p> <h2 id="init"><a href="#init" class="header-anchor">#</a> Init</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor init
  84. </code></pre></div><p>Initializes a project workspace with the following structure.</p> <ul><li><code>Anchor.toml</code>: Anchor configuration file.</li> <li><code>Cargo.toml</code>: Rust workspace configuration file.</li> <li><code>package.json</code>: JavaScript dependencies file.</li> <li><code>programs/</code>: Directory for Solana program crates.</li> <li><code>app/</code>: Directory for your application frontend.</li> <li><code>tests/</code>: Directory for JavaScript integration tests.</li> <li><code>migrations/deploy.js</code>: Deploy script.</li></ul> <h2 id="migrate"><a href="#migrate" class="header-anchor">#</a> Migrate</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor migrate
  85. </code></pre></div><p>Runs the deploy script located at <code>migrations/deploy.js</code>, injecting a provider configured
  86. from the workspace's <code>Anchor.toml</code>. For example,</p> <div class="language-javascript extra-class"><pre class="language-javascript"><code><span class="token comment">// File: migrations/deploys.js</span>
  87. <span class="token keyword">const</span> anchor <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&quot;@project-serum/anchor&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  88. module<span class="token punctuation">.</span><span class="token function-variable function">exports</span> <span class="token operator">=</span> <span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">provider</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  89. anchor<span class="token punctuation">.</span><span class="token function">setProvider</span><span class="token punctuation">(</span>provider<span class="token punctuation">)</span><span class="token punctuation">;</span>
  90. <span class="token comment">// Add your deploy script here.</span>
  91. <span class="token punctuation">}</span>
  92. </code></pre></div><p>Migrations are a new feature
  93. and only support this simple deploy script at the moment.</p> <h2 id="new"><a href="#new" class="header-anchor">#</a> New</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor new &lt;program-name&gt;
  94. </code></pre></div><p>Creates a new program in the workspace's <code>programs/</code> directory initialized with boilerplate.</p> <h2 id="test"><a href="#test" class="header-anchor">#</a> Test</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor test
  95. </code></pre></div><p>Run an integration test suit against the configured cluster, deploying new versions
  96. of all workspace programs before running them.</p> <p>If the configured network is a localnet, then automatically starts the localnetwork and runs
  97. the test.</p> <div class="custom-block tip"><p class="custom-block-title">Note</p> <p>Be sure to shutdown any other local validators, otherwise <code>anchor test</code> will fail to run.</p> <p>If you'd prefer to run the program against your local validator use <code>anchor test --skip-local-validator</code>.</p></div> <p>When running tests we stream program logs to <code>.anchor/program-logs/&lt;address&gt;.&lt;program-name&gt;.log</code></p> <div class="custom-block tip"><p class="custom-block-title">Note</p> <p>The Anchor workflow <a href="https://www.parity.io/paritys-checklist-for-secure-smart-contract-development/" target="_blank" rel="noopener noreferrer">recommends<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>
  98. to test your program using integration tests in a language other
  99. than Rust to make sure that bugs related to syntax misunderstandings
  100. are coverable with tests and not just replicated in tests.</p></div> <h2 id="upgrade"><a href="#upgrade" class="header-anchor">#</a> Upgrade</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor upgrade &lt;target/deploy/program.so&gt; --program-id &lt;program-id&gt;
  101. </code></pre></div><p>Uses Solana's upgradeable BPF loader to upgrade the on chain program code.</p> <h2 id="verify"><a href="#verify" class="header-anchor">#</a> Verify</h2> <div class="language- extra-class"><pre class="language-text"><code>anchor verify &lt;program-id&gt;
  102. </code></pre></div><p>Verifies the on-chain bytecode matches the locally compiled artifact.</p></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
  103. <a href="/anchor/tutorials/tutorial-4.html" class="prev">
  104. Errors
  105. </a></span> <span class="next"><a href="/anchor/getting-started/verification.html">
  106. Verifiable Builds
  107. </a>
  108. </span></p></div> </main></div><div class="global-ui"></div></div>
  109. <script src="/anchor/assets/js/app.b2f13cd7.js" defer></script><script src="/anchor/assets/js/2.90291299.js" defer></script><script src="/anchor/assets/js/10.99d917b5.js" defer></script>
  110. </body>
  111. </html>