This smart contract is a secure multi-signature wallet implemented in the Clarity programming language for the Stacks blockchain. It allows multiple owners to collaboratively approve and execute transactions, ensuring enhanced security and shared control over funds.
- Multi-Signature Support: Requires a minimum number of owner approvals before executing a transaction.
- Proposals: Owners can propose transactions specifying the recipient and the amount.
- Signatures: Owners can sign proposals, ensuring consensus is reached before funds are transferred.
- Execution: Automatically executes the transaction once the required number of signatures is collected.
- Security: Includes checks to prevent unauthorized access, duplicate signatures, or re-execution of transactions.
Error codes used for assertions and validations:
ERR-NOT-OWNER (u1): The caller is not an authorized owner.ERR-INSUFFICIENT-SIGNATURES (u2): Proposal lacks the required number of signatures.ERR-PROPOSAL-NOT-FOUND (u3): The specified proposal does not exist.ERR-ALREADY-SIGNED (u4): The owner has already signed the proposal.ERR-TRANSACTION-ALREADY-EXECUTED (u5): The transaction has already been executed.ERR-TRANSACTION-FAILED (u6): The STX transfer failed.
- Owners: A map of wallet owners (
principal -> bool). - Proposals: A map storing proposals with:
signatures: List of owner signatures.executed: Boolean indicating if the transaction is executed.to: Recipient of the transaction.amount: Amount of STX to transfer.
next-proposal-id: Counter for unique proposal IDs.required-signatures: Number of owner signatures required to execute a transaction.
Initializes the wallet by:
- Adding the specified owners.
- Setting the minimum required signatures.
Creates a new transaction proposal. Only wallet owners can propose.
Allows owners to sign a proposal. If the required signatures are met, the transaction is executed.
Adds an owner to the owners' map.
Checks if the caller is a wallet owner.
Executes the transaction once it has sufficient signatures.
Returns the recipient of the specified proposal.
Returns the amount specified in the proposal.
Returns the list of signatures for a proposal.
Checks if a proposal has been executed.
- Initialize the Wallet: Use
initialize-walletto set up the wallet owners and the minimum signatures required for transaction approval. - Propose a Transaction: Owners can propose transactions by specifying the recipient and the amount using
propose-transaction. - Sign a Proposal: Other owners review and sign the proposal using
sign-proposal. - Execute the Transaction: Once the required number of signatures is collected, the contract automatically executes the transaction and transfers STX to the recipient.
The contract ensures robustness with various error checks, such as verifying ownership, preventing duplicate signatures, and ensuring proposals exist before execution.
- A maximum of 10 owners is supported (
list 10 principal). - Signatures are capped at 10 per proposal.
- Clarity development environment (e.g., Stacks CLI or a Clarity IDE).
- Wallet for deploying the contract and funding transactions.
- Deploy the contract using your preferred Clarity tool.
- Call
initialize-walletto set up the wallet. - Use the provided public functions to propose, sign, and execute transactions.
This project is open-source and available under the MIT License.