Skip to content

About

A developer kit for managing multisignature wallets on ethereum.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Hey guys, today I present you my DevKit for Multisignature Approvals. This kit simplifies the creation and management of multisignature contracts for decentralized governance or approval systems. Let’s dive straight into how to use it!

Overview

This DevKit includes:

  1. Smart Contracts:

    • MultiSigApproval: For creating proposals and managing approvals.
    • MultiSigApprovalFactory: For deploying new MultiSigApproval contracts.
  2. SDK: A JavaScript/TypeScript library to interact with the contracts.

  3. Utility Functions: Helper methods for working with addresses and transactions.

Installation

  1. Clone the repository:
    git clone https://github.com/Paulilami/multisig-devkit
    cd multisig-devkit
  2. Install dependencies:
    npm install
  3. Compile the contracts:
    npx hardhat compile

Deploying Contracts

First, deploy the MultiSigApprovalFactory contract:

const { ethers } = require("hardhat");

async function main() {
    const [deployer] = await ethers.getSigners();
    const Factory = await ethers.getContractFactory("MultiSigApprovalFactory", deployer);
    const factory = await Factory.deploy();

    console.log("Factory deployed at:", factory.address);
}

main();

Using the SDK

Setup

import { ethers } from "ethers";
import { MultiSigSDK } from "./path/to/sdk";

const provider = new ethers.JsonRpcProvider("<YOUR_RPC_URL>");
const signer = provider.getSigner();
const factoryAddress = "<DEPLOYED_FACTORY_ADDRESS>";

const sdk = new MultiSigSDK(provider, factoryAddress);

Create a MultiSig Contract

(async () => {
    const approvers = [
        "0x1234567890abcdef1234567890abcdef12345678",
        "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
        "0x9876543210fedcba9876543210fedcba98765432",
    ];

    const contractAddress = await sdk.createMultiSig(approvers, signer);
    console.log("New MultiSig contract deployed at:", contractAddress);
})();

Create a Proposal

(async () => {
    sdk.connectToMultiSig("<DEPLOYED_MULTISIG_CONTRACT_ADDRESS>", provider);
    const proposalId = await sdk.createProposal(2, signer); // example: requires 2 approvals
    console.log("Created proposal with ID:", proposalId);
})();

Approve a Proposal

(async () => {
    const proposalId = 1; // replace with proposal ID
    await sdk.approveProposal(proposalId, signer);
    console.log("Proposal approved.");
})();

Check Proposal Status

(async () => {
    const proposalId = 1; // replace with proposal ID
    const isApproved = await sdk.checkProposal(proposalId);
    console.log("Proposal approved:", isApproved);
})();

Execute a Proposal

(async () => {
    const proposalId = 1; // replace with actual proposal ID
    await sdk.executeProposal(proposalId, signer);
    console.log("Proposal executed.");
})();

Utilities

  • validateAddress: Check if an address is valid.
  • toChecksumAddress: Convert an address to checksum format.

Example Usage

Here is a complete example:

(async () => {
    const sdk = new MultiSigSDK(provider, factoryAddress);

    // create MultiSig contract
    const approvers = [
        "0x1234567890abcdef1234567890abcdef12345678",
        "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
        "0x9876543210fedcba9876543210fedcba98765432",
    ];
    const contractAddress = await sdk.createMultiSig(approvers, signer);

    // connect to the MultiSig contract
    sdk.connectToMultiSig(contractAddress, provider);

    // create a proposal
    const proposalId = await sdk.createProposal(2, signer);

    // Approve the proposal
    await sdk.approveProposal(proposalId, signer);

    // check if the proposal is approved
    const isApproved = await sdk.checkProposal(proposalId);
    console.log("Proposal Approved:", isApproved);

    // execute the proposal
    await sdk.executeProposal(proposalId, signer);
})();

Conclusion

This DevKit simplifies the entire process of creating, managing, and executing multisignature approvals. It’s easy to set up and works seamlessly with Ethereum-compatible blockchains. Please note: I'm currently still developing the sdk but the contracts are fully working.

Feel free to reach out if you have any questions or need further assistance!

About

A developer kit for managing multisignature wallets on ethereum.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages