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.

  • Allows interaction with external contracts using their deployed address and ABI, extending the wallet's functionality.

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.

multsig wallet

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!

Project Structure

  • contracts: Contains the Hardhat-based Smart Contracts.

  • client: Contains the React Application that interacts with the Smart Contracts.

Contracts

The Contracts projects includes;

  • MultiSig Wallet Contract: The MultiSigWallet contract's core functions revolve around creating, approving, and executing token transfers and transactions, managed by a set list of approvers. The constructor initializes the contract with approvers, a quorum, and a name. Approvers can create new transfer requests using createTransfer and approve them with approveTransfer, which executes the transfer if the quorum is met. Similarly, they can create transactions with arbitrary data using createTransaction and approve them with approveTransaction, executing the transaction upon reaching the quorum. The contract can receive funds through the receive function, and the onlyApprover modifier ensures only authorized approvers can initiate or approve actions. Functions like getApprovers, getTransfers, and getTransaction provide visibility into the approvers, transfers, and transactions, respectively.. View Contract

  • MultiSig Wallet Factory Contract: The MultiSigWalletFactory contract facilitates the creation and tracking of multi-signature wallets (MultiSigWallet instances) on the Ethereum blockchain. It includes functionality to create new wallets with specified sets of approvers and a quorum requirement. Upon creation, each wallet's address is associated with the participating approvers through a mapping, allowing easy retrieval of wallets associated with any given approver. The factory contract maintains a list of all created wallet addresses, enabling visibility into all active wallets spawned from it. Key functions include createWallet, which initializes a new MultiSigWallet instance, updates mappings, emits an event upon creation, and returns the wallet's address. This design supports decentralized applications needing secure multi-party approval mechanisms by providing a scalable and transparent method to manage multiple multi-signature wallets and their signers/approvers. View Contract

  • Sample Smart Contract (ExternalContract): A contract used to test the MultiSig wallet's transaction builder feature. View Contract

Client

If you re done cloning the repo above, then proceed to setup the React app on your machine. Navigate to the client sub-folder

$ cd client

then install dependancies and start the application

# Install dependencies
$ yarn install

# Run app
$ yarn dev

Client Contract Interaction

The React application contains two Js classes for interacting with the core contracts. which are

Client features

  1. Viewing and Creating MultiSig Wallets: After successfully connecting a web3 wallet (e.g., MetaMask), the index page ("/") displays a list of multisig wallets where the connected address is one of the approvers (signers). The output of the page is shown below.

    multisig wallets List

    To add a new multisig wallet, click on the "Create Wallet" button, fill in the necessary details in the form that appears, and submit the form.

    Create Wallet
  2. Transfers: On the index page, clicking the View Wallet button for a specific multisig wallet will navigate to a page that displays a list of transfers (both approved and pending) for the selected wallet. The connected approver can approve any transfer on the list by clicking the Approve button for that particular transfer.

    Transfer List

    To create a new transfer, click on the Add Transfer button, fill in the necessary details in the form that appears, and submit the form.

    Create Transfer
  3. Transactions: After selecting a multisig wallet on the index page, click on the Transactions tab button to navigate to a page that displays a list of transactions (both executed and pending) for the selected wallet. The connected approver can approve any transaction on the list by clicking the "Approve" button for that particular transfer.

    Transactions List

    To create a new transaction, click on the "Create Transfer" button. In the form that appears, you can either use the sample external contract address and ABI or another contract deployed on the AssetChain Testnet network. Select the function you want to execute, fill in the selected function's parameters, and submit the form.

    Create Transaction

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

Last updated