This multi-signature contract is designed for secure transactions on blockchain platforms, requiring multiple signatures to authorize a transaction. It enables you to:
- Set up a multi-signature wallet with a list of authorized signatories.
- Define a threshold for the number of signatures required to approve transactions.
- Update the list of signatories and threshold as needed.
- Enforce spending limits for transactions.
For a comprehensive understanding of the contract's architecture, design decisions, and implementation details, please refer to the Design Documentation. This documentation provides in-depth insights into the contract's design, including its components, and detailed explanations of its functionality.
The multisig_validator
function is responsible for:
- Validation of Signatures: Checks if the number of valid signers meets or exceeds the threshold required for the transaction.
- Spending Limit Enforcement: Ensures that the transaction adheres to the spending limit specified in the contract.
- Datum Validation: Validates that the contract's datum is correctly updated, if applicable.
-
get_asset_amount
: Retrieves the amount of a specific asset from aValue
. -
validate_sign
: This function ensures that a transaction with aSign
redeemer is valid under the following conditions:-
The amount being transferred from the input to the output does not exceed the spending limit defined in the contract.
-
The datum associated with the output UTxO is consistent with the expectations and rules defined in the contract.
-
-
datum_is_valid
: Ensures that the datum has not been altered inappropriately. -
validate_update
: Validates updates to the contract, including changes to the list of signatories and the threshold.
Before you can deploy and test this multi-signature contract, ensure that you have the Aiken compiler installed to write and compile your contract. Follow the Aiken installation instructions to get started.
To build the project, Here are the steps to compile and run the included tests:
- Clone the repo and navigate inside:
git clone https://github.com/Anastasia-Labs/aiken-upgradable-multisig
cd aiken-upgradable-multisig
- Run the build command, which both compiles all the functions/examples and also runs the included unit tests:
aiken build
Several test cases are provided to ensure the contract behaves as expected:
success_sign
: Tests a successful transaction signing scenario where the number of signatures meets the threshold.reject_insufficient_signatures
: Tests the rejection of a transaction when insufficient signatures are provided.success_adjust_threshold
: Tests the successful adjustment of the signature threshold.success_add_signer
: Tests the successful addition of a new signer to the contract.success_remove_signer
: Tests the successful removal of a signer from the contract.
To demonstrate and validate these following functionalities,
- Secure Spending of Assets
- Seamless Adjustment of Signer Thresholds
- Dynamic Addition or Removal of Signers
We have prepared comprehensive test cases. For detailed evidence and to view the test cases associated with these criteria, please refer to the Test Documentation
To run all tests, simply do:
aiken check
Test results:
Each test case is designed to validate specific aspects of the multi-signature contract,To run only specific tests, do:
aiken check -m `test_case_function_name`