github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/dev/wasm/escrow/Publishing.md (about)

     1  # Publishing Contracts
     2  
     3  This is an overview of how to publish the contract's source code in this repo.
     4  We use Cargo's default registry [crates.io](https://crates.io/) for publishing contracts written in Rust.
     5  
     6  ## Preparation
     7  
     8  Ensure the `Cargo.toml` file in the repo is properly configured. In particular, you want to
     9  choose a name starting with `cw-`, which will help a lot finding CosmWasm contracts when
    10  searching on crates.io. For the first publication, you will probably want version `0.1.0`.
    11  If you have tested this on a public net already and/or had an audit on the code,
    12  you can start with `1.0.0`, but that should imply some level of stability and confidence.
    13  You will want entries like the following in `Cargo.toml`:
    14  
    15  ```toml
    16  name = "cw-escrow"
    17  version = "0.1.0"
    18  description = "Simple CosmWasm contract for an escrow with arbiter and timeout"
    19  repository = "https://github.com/CosmWasm/cosmwasm-examples"
    20  ```
    21  
    22  You will also want to add a valid [SPDX license statement](https://spdx.org/licenses/),
    23  so others know the rules for using this crate. You can use any license you wish,
    24  even a commercial license, but we recommend choosing one of the following, unless you have
    25  specific requirements.
    26  
    27  * Permissive: [`Apache-2.0`](https://spdx.org/licenses/Apache-2.0.html#licenseText) or [`MIT`](https://spdx.org/licenses/MIT.html#licenseText)
    28  * Copyleft: [`GPL-3.0-or-later`](https://spdx.org/licenses/GPL-3.0-or-later.html#licenseText) or [`AGPL-3.0-or-later`](https://spdx.org/licenses/AGPL-3.0-or-later.html#licenseText)
    29  * Commercial license: `Commercial` (not sure if this works, I cannot find examples)
    30  
    31  It is also helpful to download the LICENSE text (linked to above) and store this
    32  in a LICENSE file in your repo. Now, you have properly configured your crate for use
    33  in a larger ecosystem.
    34  
    35  ### Updating schema
    36  
    37  To allow easy use of the contract, we can publish the schema (`schema/*.json`) together
    38  with the source code.
    39  
    40  ```sh
    41  cargo schema
    42  ```
    43  
    44  Ensure you check in all the schema files, and make a git commit with the final state.
    45  This commit will be published and should be tagged. Generally, you will want to
    46  tag with the version (eg. `v0.1.0`), but in the `cosmwasm-examples` repo, we have
    47  multiple contracts and label it like `escrow-0.1.0`. Don't forget a
    48  `git push && git push --tags`
    49  
    50  ### Note on build results
    51  
    52  Build results like Wasm bytecode or the expected hash don't need to be committed, since
    53  they don't belong to the source publication.
    54  An optimized build will be automatically done on release tags by the CI build, and its
    55  results will attached to the release.
    56  
    57  A single source code can be built with multiple different optimizers, so
    58  we should not make any strict assumptions on the tooling that will be used.
    59  
    60  ## Publishing
    61  
    62  Now that your package is properly configured and all artifacts are committed, it
    63  is time to share it with the world.
    64  Please refer to the [complete instructions for any questions](https://rurust.github.io/cargo-docs-ru/crates-io.html),
    65  but I will try to give a quick overview of the happy path here.
    66  
    67  ### Registry
    68  
    69  You will need an account on [crates.io](https://crates.io) to publish a rust crate.
    70  If you don't have one already, just click on "Log in with GitHub" in the top-right
    71  to quickly set up a free account. Once inside, click on your username (top-right),
    72  then "Account Settings". On the bottom, there is a section called "API Access".
    73  If you don't have this set up already, create a new token and use `cargo login`
    74  to set it up. This will now authenticate you with the `cargo` cli tool and allow
    75  you to publish.
    76  
    77  ### Uploading
    78  
    79  Once this is set up, make sure you commit the current state you want to publish.
    80  Then try `cargo publish --dry-run`. If that works well, review the files that
    81  will be published via `cargo package --list`. If you are satisfied, you can now
    82  officially publish it via `cargo publish`.
    83  
    84  Congratulations, your package is public to the world.
    85  
    86  ### Sharing
    87  
    88  Once you have published your package, people can now find it by
    89  [searching for "cw-" on crates.io](https://crates.io/search?q=cw).
    90  But that isn't exactly the simplest way. To make things easier and help
    91  keep the ecosystem together, we suggest making a PR to add your package
    92  to the [`cawesome-wasm`](https://github.com/cosmwasm/cawesome-wasm) list.
    93  
    94  ### Organizations
    95  
    96  Many times you are writing a contract not as a solo developer, but rather as
    97  part of an organization. You will want to allow colleagues to upload new
    98  versions of the contract to crates.io when you are on holiday.
    99  [These instructions show how]() you can set up your crate to allow multiple maintainers.
   100  
   101  You can add another owner to the crate by specifying their github user. Note, you will
   102  now both have complete control of the crate, and they can remove you:
   103  
   104  `cargo owner --add ethanfrey`
   105  
   106  You can also add an existing github team inside your organization:
   107  
   108  `cargo owner --add github:confio:developers`
   109  
   110  The team will allow anyone who is currently in the team to publish new versions of the crate.
   111  And this is automatically updated when you make changes on github. However, it will not allow
   112  anyone in the team to add or remove other owners.