anchor/assets/js/14.258e35e3.js

1 line
8.5 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[14],{408:function(t,e,a){"use strict";a.r(e);var r=a(29),s=Object(r.a)({},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"publishing-source"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#publishing-source"}},[t._v("#")]),t._v(" Publishing Source")]),t._v(" "),a("p",[t._v("The Anchor Program Registry at "),a("a",{attrs:{href:"https://anchor.projectserum.com",target:"_blank",rel:"noopener noreferrer"}},[t._v("anchor.projectserum.com"),a("OutboundLink")],1),t._v("\nhosts a catalog of verified programs on Solana both written with and without Anchor. It is recommended\nthat authors of smart contracts publish their source to promote best\npractices for security and transparency.")]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("note")]),t._v(" "),a("p",[t._v("The Anchor Program Registry is currently in alpha testing. For access to publishing\nplease ask on "),a("a",{attrs:{href:"https://discord.gg/rg5ZZPmmTm",target:"_blank",rel:"noopener noreferrer"}},[t._v("Discord"),a("OutboundLink")],1),t._v(".")])]),t._v(" "),a("h2",{attrs:{id:"getting-started"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#getting-started"}},[t._v("#")]),t._v(" Getting Started")]),t._v(" "),a("p",[t._v("The process for publishing is mostly identical to "),a("code",[t._v("crates.io")]),t._v(".")]),t._v(" "),a("ul",[a("li",[t._v("Signup for an account "),a("a",{attrs:{href:"https://anchor.projectserum.com/signup",target:"_blank",rel:"noopener noreferrer"}},[t._v("here"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("li",[t._v("Confirm your email by clicking the link sent to your address.")]),t._v(" "),a("li",[t._v("Navigate to your Username -> Account Settings on the top navbar.")]),t._v(" "),a("li",[t._v('Click "New Token" in the '),a("strong",[t._v("API Access")]),t._v(" section.")]),t._v(" "),a("li",[t._v("Run "),a("code",[t._v("anchor login <token>")]),t._v(" at the command line.")])]),t._v(" "),a("p",[t._v("And you're ready to interact with the registry.")]),t._v(" "),a("h2",{attrs:{id:"configuring-a-build"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#configuring-a-build"}},[t._v("#")]),t._v(" Configuring a Build")]),t._v(" "),a("p",[t._v("Whether your program is written in Anchor or not, all source being published must\nhave an "),a("code",[t._v("Anchor.toml")]),t._v(" to define the build.")]),t._v(" "),a("p",[t._v("An example "),a("code",[t._v("Anchor.toml")]),t._v(" config looks as follows,")]),t._v(" "),a("div",{staticClass:"language-toml extra-class"},[a("pre",{pre:!0,attrs:{class:"language-toml"}},[a("code",[a("span",{pre:!0,attrs:{class:"token key property"}},[t._v("anchor_version")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"0.24.2"')]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token table class-name"}},[t._v("workspace")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token key property"}},[t._v("members")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"programs/multisig"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token table class-name"}},[t._v("provider")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token key property"}},[t._v("cluster")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"mainnet"')]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token key property"}},[t._v("wallet")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"~/.config/solana/id.json"')]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token table class-name"}},[t._v("programs.mainnet")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token key property"}},[t._v("multisig")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"A9HAbnCwoD6f2NkZobKFf6buJoN9gUVVvX5PoUnDHS6u"')]),t._v("\n\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token table class-name"}},[t._v("programs.localnet")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token key property"}},[t._v("multisig")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"A9HAbnCwoD6f2NkZobKFf6buJoN9gUVVvX5PoUnDHS6u"')]),t._v("\n")])])]),a("p",[t._v("Here there are four sections.")]),t._v(" "),a("ol",[a("li",[a("code",[t._v("anchor_version")]),t._v(" (optional) - sets the anchor docker image to use. By default, the builder will use the latest version of Anchor.")]),t._v(" "),a("li",[a("code",[t._v("[workspace]")]),t._v(" (optional) - sets the paths--relative to the "),a("code",[t._v("Anchor.toml")]),t._v("--\nto all programs in the local\nworkspace, i.e., the path to the "),a("code",[t._v("Cargo.toml")]),t._v(" manifest associated with each\nprogram that can be compiled by the "),a("code",[t._v("anchor")]),t._v(" CLI. For programs using the\nstandard Anchor workflow, this can be ommitted. For programs not written in Anchor\nbut still want to publish, this should be added.")]),t._v(" "),a("li",[a("code",[t._v("[provider]")]),t._v(" - configures the wallet and cluster settings. Here, "),a("code",[t._v("mainnet")]),t._v(" is used because the registry only supports "),a("code",[t._v("mainnet")]),t._v(" binary verification at the moment.")]),t._v(" "),a("li",[a("code",[t._v("[programs.mainnet]")]),t._v(" - configures each program in the workpace, providing\nthe "),a("code",[t._v("address")]),t._v(" of the program to verify.")])]),t._v(" "),a("div",{staticClass:"custom-block tip"},[a("p",{staticClass:"custom-block-title"},[t._v("TIP")]),t._v(" "),a("p",[t._v("When defining program in "),a("code",[t._v("[programs.mainnet]")]),t._v(", make sure the name provided\nmatches the "),a("strong",[t._v("lib")]),t._v(" name for your program, which is defined\nby your program's Cargo.toml.")])]),t._v(" "),a("h3",{attrs:{id:"examples"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#examples"}},[t._v("#")]),t._v(" Examples")]),t._v(" "),a("h4",{attrs:{id:"anchor-program"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#anchor-program"}},[t._v("#")]),t._v(" Anchor Program")]),t._v(" "),a("p",[t._v("An example of a toml file for an Anchor program can be found "),a("a",{attrs:{href:"https://anchor.projectserum.com/build/2",target:"_blank",rel:"noopener noreferrer"}},[t._v("here"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h4",{attrs:{id:"non-anchor-program"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#non-anchor-program"}},[t._v("#")]),t._v(" Non Anchor Program")]),t._v(" "),a("p",[t._v("An example of a toml file for a non-anchor program can be found "),a("a",{attrs:{href:"https://anchor.projectserum.com/build/1",target:"_blank",rel:"noopener noreferrer"}},[t._v("here"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"publishing"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#publishing"}},[t._v("#")]),t._v(" Publishing")]),t._v(" "),a("p",[t._v("To publish to the Anchor Program Registry, change directories to the "),a("code",[t._v("Anchor.toml")]),t._v("\ndefined root and run")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v("anchor publish "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("program-name"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("\n")])])]),a("p",[t._v("where "),a("code",[t._v("<program-name>")]),t._v(" is as defined in "),a("code",[t._v("[programs.mainnet]")]),t._v(", i.e., "),a("code",[t._v("multisig")]),t._v("\nin the example above.")])])}),[],!1,null,null,null);e.default=s.exports}}]);