Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of the Archway multisig hub installation guide #408

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 239 additions & 0 deletions content/2.developers/3.guides/6.multisig/1.archway-multiSig-hub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
---
objectID: developers_guides_archway-multisig-hub
title: Archway multisig hub
description: This guide provides step-by-step instructions for deploying a MultiSig solution on the Archway blockchain
parentSection: Developers
parentSectionPath: /developers
---

# Introduction

Welcome to our step-by-step guide on deploying a MultiSig solution on the Archway blockchain. If you prefer a visual tutorial, there's a video walkthrough of this guide below. A basic installation guide is also available within the <a href="https://github.com/archway-network/archway-msig" target="_blank">Archway MultiSig Hub</a> repo.

::youtubeEmbed{src="https://www.youtube.com/embed/_ISNdeGk-o0" tailwindClasses="w-full lg:w-3/4 h-96"}
::

## Prerequisites

- Mac or Linux
- Node version `16` or above installed. Avoid using Node version `20.6` due to known issues.
- NPM version `8` or above


## Step 1: Installing dependencies

Before diving in, ensure that you have all necessary dependencies installed. You will need to install both the **jq** and **Archway CLI** packages.

### jq

The **jq** package is required by the script used to Instantiate the multisig contracts.

On Linux:

```bash
sudo apt install jq
```

On MacOS (with Homebrew):

```bash
brew install jq
```

### Archway cli (v2 beta)

The **Archway CLI** package is required for executing transactions on the Archway blockchain. We'll be installing version 2 of the package, which is still in Beta.

```bash
npm install -g @archwayhq/cli@pre
```

## Step 2: Configure archwway cli

Let's configure a default **chain-id** for the Archway CLI environment.

Confirm which network to deploy to: **Mainnet** (archway-1) or **Testnet** (constantine-3).

Adjust the **chain-id** config:

For Testnet:

```bash
archway config chain-id constantine-3 --global
```

For Mainnet:

```bash
archway config chain-id archway-1 --global
```

Verify the configured **chain-id**:

```bash
archway config show
```

## Step 3: Preparing accounts

With our environment configured, it's time to add at least one account to the Archway CLI keystore which is required for executing transactions on chain. You could also set up additional accounts at this stage if desired as you will need at least two accounts in order to instantiate the multisig contracts.

Execute the following command to create a new account:

```bash
archway accounts new
```

Write down the **mnemonic** phrase displayed and store it in a safe place. You will need to import this **mnemonic** phrase into Keplr for example, to interact with the Multisig UI later on.

To use an existing account:

```bash
archway accounts new [account-name] --recover
```

Check your accounts:

```bash
archway accounts list
```

After creating the account you will need to fund the account with **ARCH** tokens to execute transactions on **Mainnet** and if you're using the **Testnet** you will need to get **CONST** tesstnet tokens. You can get **CONST** testnet tokens from the Archway Discord’s <a href="https://discord.com/channels/892203409418092615/933050911662690334" target="_blank">#testnet-faucet</a> channel.


## Step 4: Clone multiSig repository

With the dependencies set, and at least one account set up within Achway CLI, let’s clone the multisig repository.

```bash
git clone git@github.com:archway-network/archway-msig.git
cd archway-msig
npm install
```

Change into the newly created directory and execute the following command to install the packages required by the multisig:

```bash
npm install
```

## Step 5: Configuring multiSig script

Now we need to configure the multisig script that will be used to create the contracts on-chain. Edit the following file: **scripts/instantiate/multisig_params.json**.

This file holds the initial parameters for the new multisig.

Some parameters like **max_voting_period_in_seconds** and **members** can always be amended by the multisig owners but the other fields are immutable after deployment.

- The **sender_account** is the account that will sign the transaction. It must be an existing funded account in the Archway CLI keystore. This would be one of the accounts created previously.
- The **name** is the name of this multisig. It can help to give the multisig application an appropriate label if you plan to deploy multiple multisigs within this project.
- The **description** is a short text description of the multi-sig for reference.
- **Image-url** is a URL to an image to be displayed in the UI.
- The **max_voting_period_in_seconds** is the voting period for multi-sig proposals, expressed in seconds.
- **Members** is the members of the multisig which includes their addresses and voting power. Any number of addresses can be added here, but there must be at least 2 to begin with.

### Step 6: Deploy the multiSig contracts

In the console, enter the following command from the root of your project to deploy the multisig contracts:

```bash
bash scripts/instantiate/instantiate_contracts.sh
```

If successful, the transaction hash, and the resulting contract addresses will be displayed. Also a new file named **multisig_contracts_result.json** will be created in the **scripts/instantiate** directory, containing the resulting contract addresses. These contract addresses will need to be copied into the project's **.env** file which we will create next.

## Step 7: Set Uup multiSig environment

Now let’s set up your MultiSig environment. You will need to create a **.env** file from the **.env.example** file and then add the **DOADAO_CONTRACTS** values from the results file created previously.

Copy the contract addresses from **multisig_contracts_result.json** into the **DAODAO_CONTRACTS** section of the **.env** file and edit the other fields as needed:
- **RUNTIME_ENVIRONMENT**: Set as `mainnet` or `testnet`.
- **APP_NAME**: Your project's name.
- **APP_LOGO**: Logo image path.
- **APP_BRAND**: Optional textual logo image path.
- **DAODAO_CONTRACTS**: A JSON array of multisig contracts (to be updated after deployment).


## Step 8: Launching the development server

To view and interact with the frontend UI, start the development server:

```bash
npm run dev
```

This will set up a local testing server and you will be able to browse the multisig UI by visiting on of the addresses shown. Head over to <a href="http://localhost:3000">http://localhost:3000</a> to see your MultiSig in action!

## Step 9: Preparing for production

Build the application:

```bash
npm run build
```

Preview the build locally:

```bash
npm run preview
```

## Step 7: Deploying to hosting platforms

### Firebase

If you don't have done it already, install the firebase functions globally, and login to your account

```bash
npm install -g firebase-tools@latest
firebase login
firebase init hosting
```

Modify the `.firebaserc` file to have your firebase project id as the default

```json
{
"projects": {
"default": "<your-firebase-project-id>"
}
}
```


Then modify the `firebase.json` file to contain the following:

```json
{
"functions": { "source": ".output/server" },
"hosting": {
"site": "<your-firebase-project-id>",
"public": ".output/public",
"cleanUrls": true,
"rewrites": [{ "source": "**", "function": "server" }]
}
}
```

Also install the firebase packages as local dependencies to be used during the build process:

```bash
npm install -D firebase-admin firebase-functions
```

And then you can build and deploy with the following commands:

```bash
NITRO_PRESET=firebase npm run build
npx firebase-tools deploy
```


### Vercel

Import your Github project into Vercel, and it will automatically enable the correct settings for your deployment.


### Other Platforms

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.