github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/how-to-guides/deploy.md (about)

     1  ---
     2  id: deploy
     3  ---
     4  
     5  # How to deploy a Realm / Package
     6  
     7  ## Overview
     8  
     9  This guide shows you how to deploy any realm or package to the Gno chain,
    10  including how to:
    11  - deploy Gno code in your browser via the Playground, 
    12  - deploy Gno code from your local machine using `gnokey`'s `maketx addpkg` API.
    13  
    14  ## Deployment via the Playground
    15  
    16  Deployment via the Playground is recommended for smaller realms and packages.
    17  For larger projects, it is recommended to write, test, and deploy your code from
    18  a more appropriate environment, such as a local or online IDE.
    19  
    20  For this, check out the [**Deployment from a local environment**](#deployment-from-a-local-environment) section.
    21  
    22  ### Prerequisites
    23  
    24  - **A Gno.land-compatible wallet, such as [Adena](https://adena.app)**
    25  
    26  ### Using Gno Playground
    27  
    28  To demonstrate deployment using the Playground, we'll use the **Counter** realm.
    29  You can access the sample code via
    30  [this Playground link](https://play.gno.land/p/iUWTha99D1J).
    31  
    32  Review the code and when you're ready, click on "**Deploy**".
    33  Ensure your wallet is connected to proceed. If it isn't, a prompt will appear for connection:
    34  
    35  ![DeployConnect](../assets/how-to-guides/deploy/deploy_connect.png)
    36  
    37  After connecting your wallet to the Playground, you will be prompted with a 
    38  new toolbox:
    39  
    40  ![DeployDefault](../assets/how-to-guides/deploy/deploy_default.png)
    41  
    42  Here, you can choose the deployment path of your realm or package, as well as the network
    43  to deploy to. The Playground also allows for deployment to a local node
    44  if you are running one.
    45  
    46  :::info
    47  Here are a few things to keep in mind when deploying packages and realms:
    48  - The `name` field in the path should match your package name, in this case `counter`.
    49  - Packages are deployed under `p/`, while realms are deployed under `r/`.
    50  
    51  An example path for the Counter realm could be the following: 
    52  ```go
    53  gno.land/r/<your_username>/counter
    54  ```
    55  :::
    56  
    57  After choosing a path and network, click on **Deploy**. A pop-up window
    58  from your connected wallet will prompt you to sign and approve the deployment transaction.
    59  
    60  ![DeployDefault](../assets/how-to-guides/deploy/deploy_success.png)
    61  
    62  If all went well, you will have successfully deployed your the Counter package.
    63  Congratulations 🎉
    64  
    65  ## Deployment from a local environment
    66  
    67  ### Prerequisites
    68  
    69  - **Have `gnokey` installed**
    70  - **Have access to a `gnoland` node (local or remote)**
    71  - **Have generated a keypair with `gnokey` & funded it with `gnot`**
    72  - **Have a Realm or Package ready to deploy**
    73  
    74  ### Deploying
    75  
    76  To illustrate deployment, we will use a realm. Consider the following folder
    77  structure on a local file system:
    78  
    79  ```
    80  counter-app/
    81  ├─ r/
    82  │  ├─ counter/
    83  │  │  ├─ counter.gno
    84  ```
    85  
    86  We would like to deploy the realm found in `counter.gno`. To do this, open a
    87  terminal at `counter-app/` and use the following `gnokey` command:
    88  
    89  ```bash
    90  gnokey maketx addpkg \
    91  --pkgpath "gno.land/r/demo/counter" \
    92  --pkgdir "./r/counter" \
    93  --gas-fee 10000000ugnot \
    94  --gas-wanted 800000 \
    95  --broadcast \
    96  --chainid dev \
    97  --remote localhost:26657 \
    98  MyKey
    99  ```
   100  
   101  Let's analyze all of the flags in detail:
   102  - `--pkgpath` - path where the package/realm will be placed on-chain
   103  - `--pkgdir` - local path where the package/realm is located
   104  - `--gas-wanted` - the upper limit for units of gas for the execution of the 
   105  transaction - similar to Solidity's gas limit
   106  - `--gas-fee` - similar to Solidity's gas-price
   107  - `--broadcast` - broadcast the transaction on-chain
   108  - `--chain-id` - id of the chain to connect to - local or remote
   109  - `--remote` - `gnoland` node endpoint - local or remote
   110  - `MyKey` - the keypair to use for the transaction
   111  
   112  :::info
   113  As of October 2023, `--gas-fee` is fixed to 1gnot (10000000ugnot), with plans 
   114  to change it down the line.
   115  :::
   116  
   117  Next, confirm the transaction with your keypair passphrase. If deployment was 
   118  successful, you will be presented with a message similar to the following:
   119  
   120  ```
   121  OK!
   122  GAS WANTED: 800000
   123  GAS USED:   775097
   124  ```
   125  Depending on the size of the package/realm, you might need to increase amount 
   126  given in the `--gas-wanted` flag to cover the deployment cost.
   127  
   128  :::info
   129  Regardless of whether you're deploying a realm or a package, you will be using 
   130  `gnokey`'s `maketx addpkg` - the usage of `maketx addpkg` in both cases is identical.
   131  To read more about the `maketx addpkg`
   132  subcommand, view the `gnokey` [reference](../gno-tooling/cli/gnokey.md#addpkg).
   133  :::
   134  
   135  
   136  ## Conclusion
   137  
   138  That's it 🎉
   139  
   140  You have now successfully deployed a realm/package to a Gno.land chain.