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!
This DevKit includes:
-
Smart Contracts:
MultiSigApproval: For creating proposals and managing approvals.MultiSigApprovalFactory: For deploying newMultiSigApprovalcontracts.
-
SDK: A JavaScript/TypeScript library to interact with the contracts.
-
Utility Functions: Helper methods for working with addresses and transactions.
- Clone the repository:
git clone https://github.com/Paulilami/multisig-devkit cd multisig-devkit - Install dependencies:
npm install
- Compile the contracts:
npx hardhat compile
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();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);(async () => {
const approvers = [
"0x1234567890abcdef1234567890abcdef12345678",
"0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"0x9876543210fedcba9876543210fedcba98765432",
];
const contractAddress = await sdk.createMultiSig(approvers, signer);
console.log("New MultiSig contract deployed at:", contractAddress);
})();(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);
})();(async () => {
const proposalId = 1; // replace with proposal ID
await sdk.approveProposal(proposalId, signer);
console.log("Proposal approved.");
})();(async () => {
const proposalId = 1; // replace with proposal ID
const isApproved = await sdk.checkProposal(proposalId);
console.log("Proposal approved:", isApproved);
})();(async () => {
const proposalId = 1; // replace with actual proposal ID
await sdk.executeProposal(proposalId, signer);
console.log("Proposal executed.");
})();validateAddress: Check if an address is valid.toChecksumAddress: Convert an address to checksum format.
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);
})();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!