114 lines
24 KiB
HTML
114 lines
24 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-US">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Commands | ⚓ Anchor</title>
|
|
<meta name="generator" content="VuePress 1.8.2">
|
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚓ </text></svg>">
|
|
<meta name="description" content="">
|
|
<meta name="theme-color" content="#3eaf7c">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<link rel="preload" href="/anchor/assets/css/0.styles.21b321ec.css" as="style"><link rel="preload" href="/anchor/assets/js/app.130b905b.js" as="script"><link rel="preload" href="/anchor/assets/js/2.90291299.js" as="script"><link rel="preload" href="/anchor/assets/js/10.a81a7d6e.js" as="script"><link rel="prefetch" href="/anchor/assets/js/11.e20cdb5e.js"><link rel="prefetch" href="/anchor/assets/js/12.d30544e0.js"><link rel="prefetch" href="/anchor/assets/js/13.41fde578.js"><link rel="prefetch" href="/anchor/assets/js/14.8bf73db0.js"><link rel="prefetch" href="/anchor/assets/js/15.25c2e2bd.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.54c54ce4.js"><link rel="prefetch" href="/anchor/assets/js/20.873107aa.js"><link rel="prefetch" href="/anchor/assets/js/21.46f202de.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">
|
|
<link rel="stylesheet" href="/anchor/assets/css/0.styles.21b321ec.css">
|
|
</head>
|
|
<body>
|
|
<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">
|
|
The Anchor Book
|
|
<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">
|
|
Rust
|
|
<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">
|
|
TypeScript
|
|
<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">
|
|
GitHub
|
|
<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">
|
|
The Anchor Book
|
|
<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">
|
|
Rust
|
|
<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">
|
|
TypeScript
|
|
<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">
|
|
GitHub
|
|
<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.
|
|
For a comprehensive list of commands and options, run <code>anchor -h</code> on any
|
|
of the following subcommands.</p> <div class="language- extra-class"><pre class="language-text"><code>anchor-cli
|
|
USAGE:
|
|
anchor <SUBCOMMAND>
|
|
FLAGS:
|
|
-h, --help Prints help information
|
|
-V, --version Prints version information
|
|
SUBCOMMANDS:
|
|
build Builds the workspace
|
|
cluster Cluster commands
|
|
deploy Deploys each program in the workspace
|
|
expand Expands the macros of a program or the workspace
|
|
help Prints this message or the help of the given subcommand(s)
|
|
idl Commands for interacting with interface definitions
|
|
init Initializes a workspace
|
|
migrate Runs the deploy migration script
|
|
new Creates a new program
|
|
test Runs integration tests against a localnetwork
|
|
upgrade Upgrades a single program. The configured wallet must be the upgrade authority
|
|
verify Verifies the on-chain bytecode matches the locally compiled artifact. Run this
|
|
command inside a program subdirectory, i.e., in the dir containing the program's
|
|
Cargo.toml
|
|
</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
|
|
</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
|
|
</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/<my-program>/</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
|
|
</code></pre></div><p>This lists cluster endpoints:</p> <div class="language- extra-class"><pre class="language-text"><code>Cluster Endpoints:
|
|
* Mainnet - https://solana-api.projectserum.com
|
|
* Mainnet - https://api.mainnet-beta.solana.com
|
|
* Devnet - https://api.devnet.solana.com
|
|
* Testnet - https://api.testnet.solana.com
|
|
</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
|
|
</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
|
|
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
|
|
</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.
|
|
It's recommended to use these commands to store an IDL on chain, at a deterministic
|
|
address, as a function of nothing but the the program's ID. This
|
|
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 <target/idl/program.json> <program-id>
|
|
</code></pre></div><p>Creates an idl account, writing the given <code><target/idl/program.json></code> file into a program owned account. By default, the size of the account is double the size of the IDL,
|
|
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 <out-file.json> <program-id>
|
|
</code></pre></div><p>Fetches an IDL from the configured blockchain. For example, make sure
|
|
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
|
|
</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 <program-id>
|
|
</code></pre></div><p>Outputs the IDL account's authority. This is the wallet that has the ability to
|
|
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 <program-id>
|
|
</code></pre></div><p>Erases the IDL account's authority so that upgrades can no longer occur. The
|
|
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 <program-id> -f <target/idl/program.json>
|
|
</code></pre></div><p>Upgrades the IDL file on chain to the new <code>target/idl/program.json</code> idl.
|
|
The configured wallet must be the current authority.</p> <div class="language- extra-class"><pre class="language-text"><code>anchor idl set-authority -n <new-authority> -p <program-id>
|
|
</code></pre></div><p>Sets a new authority on the IDL account. Both the <code>new-authority</code> and <code>program-id</code>
|
|
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
|
|
</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
|
|
</code></pre></div><p>Runs the deploy script located at <code>migrations/deploy.js</code>, injecting a provider configured
|
|
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>
|
|
<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">"@project-serum/anchor"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
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>
|
|
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>
|
|
<span class="token comment">// Add your deploy script here.</span>
|
|
<span class="token punctuation">}</span>
|
|
</code></pre></div><p>Migrations are a new feature
|
|
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 <program-name>
|
|
</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
|
|
</code></pre></div><p>Run an integration test suit against the configured cluster, deploying new versions
|
|
of all workspace programs before running them.</p> <p>If the configured network is a localnet, then automatically starts the localnetwork and runs
|
|
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/<address>.<program-name>.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>
|
|
to test your program using integration tests in a language other
|
|
than Rust to make sure that bugs related to syntax misunderstandings
|
|
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 <target/deploy/program.so> --program-id <program-id>
|
|
</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 <program-id>
|
|
</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">
|
|
←
|
|
<a href="/anchor/tutorials/tutorial-4.html" class="prev">
|
|
Errors
|
|
</a></span> <span class="next"><a href="/anchor/getting-started/verification.html">
|
|
Verifiable Builds
|
|
</a>
|
|
→
|
|
</span></p></div> </main></div><div class="global-ui"></div></div>
|
|
<script src="/anchor/assets/js/app.130b905b.js" defer></script><script src="/anchor/assets/js/2.90291299.js" defer></script><script src="/anchor/assets/js/10.a81a7d6e.js" defer></script>
|
|
</body>
|
|
</html>
|