MultiSig Wallet

Introduction

In this section we'll build a MultiSig wallet on AssetChain.

This is a type of wallet in which Funds stored in it can only be moved, if the multiple signatures belonging to the different owners of the wallet, are provided.

Features include:

  • The MultiSig wallet is a 2-of-3 signature address application.

  • Each address that is a part of the quorum can create a transfer by specifying an amount and a recipient.

  • Each approved address can also authorize a transfer.

  • Each transfer needs two approvals to release and send a payment.

  • Any unauthorized address that attempts to perform the actions of a member will be denied.

We will learn some basic Solidity such as mapping or struct and how to deploy it on the Asset Chain (test network). For the frontend, we will use Reactjs.

Tutorial

Before getting started:

  1. Follow for the step-by-step on how to add AssetChain testnet to Metamask.

  2. This guide assumes you have got Testnet RWA and connected to the AssetChain Testnet Network. Learn how to do that in Testnet Faucets.

  3. Finally, clone the app files stored in the repo above.

We are ready to get started!

  1. If you re done cloning the repo above, then proceed to setup the React app on your machine.

# Install dependencies
$ yarn install

# Run app
$ yarn dev

once the above process is completed, you should see a similar page to the image below.

  • The sidebar shows a form, for creating a transfer that can be approved by the other owners of wallet.

  • The sidebar also shows a list of the addresses that own the wallet.

  • Finally the main page content, shows a list of transfers that have been created in the wallet; and a button in each row for approving them.

  1. The wallet above will be interacting with the smart contract below. This smart contract is currently deployed on Asset Chain.

  • This smart contract will store the Transfers created by the wallet owners in the struct on line 11.

  • The approvals given by the wallet owners will be stored in the approvals mapping on line 23.

  • When deploying the contract, on line 28 we will pass in the addresses of users that are owners of this wallet. They are the only ones that can give approval in this smart contract.

  • getApprovers, returns the owners of the wallet.

  • getTransfers method, returns the transfers that have been created in the system.

  1. Proceed to click the connect wallet button, and connect your wallet the app. Make sure you're on Asset Chain(testnet) network.

  2. In the SideBar component below, we use ReactJS to create a transfer that the owners of the wallet, will have to approve. This form is on the sidebar of the wallet. We also fetch the owners of the wallet in the code below.

  1. In the App component below, we fetch the transfers created in this system that the owners of the wallet, will have to approve. This is displayed in the table on the page content of the wallet. We also have a button for approving the transfers in the table.

  1. In the page below, we created a class listing the methods in our MultiSig smart contract and our interactions with them using ethers.js. This is a neat way of interacting with your contracts deployed on Asset Chain or any blockchain.

This is an overview on how to build a MultSig wallet on AssetChain.

Congratulations Champ! If you made it this far, you've built a MultiSig wallet on Asset Chain.

Below is the link to preview the completed project

If you have questions, join our Telegram and say hello 👋. We're Active!

Last updated