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.
Tutorial
Before getting started:
Follow for the step-by-step on how to add AssetChain testnet to Metamask.
This guide assumes you have got Testnet RWA and connected to the AssetChain Testnet Network. Learn how to do that in Testnet Faucets.
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 usingcreateTransfer
and approve them withapproveTransfer
, which executes the transfer if the quorum is met. Similarly, they can create transactions with arbitrary data usingcreateTransaction
and approve them withapproveTransaction
, executing the transaction upon reaching the quorum. The contract can receive funds through thereceive
function, and theonlyApprover
modifier ensures only authorized approvers can initiate or approve actions. Functions likegetApprovers
,getTransfers
, andgetTransaction
provide visibility into the approvers, transfers, and transactions, respectively.. View ContractMultiSig 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 includecreateWallet
, which initializes a newMultiSigWallet
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 ContractSample 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
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 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 theApprove
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 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
Congratulations Champ! If you made it this far, you've built a MultiSig wallet on Asset Chain.
If you have questions, join our Telegram and say hello 👋. We're Active!
Last updated