A multi-signature wallet needs more than one person to approve a transaction. This makes it safer because no single person can spend money alone.
0
0
Multi-signature wallet concept in Blockchain / Solidity
Introduction
When a group of friends want to share control of a digital wallet.
For a company to require multiple managers to approve payments.
To protect funds by needing several approvals before sending money.
When you want extra security so one lost key does not lose all funds.
Syntax
Blockchain / Solidity
multiSigWallet = {
owners: [address1, address2, address3],
requiredSignatures: 2,
transactions: [],
submitTransaction(tx) { ... },
confirmTransaction(txId, owner) { ... },
executeTransaction(txId) { ... }
}owners is the list of people who can approve transactions.
requiredSignatures is how many approvals are needed to send money.
Examples
This wallet needs 2 out of 3 owners to approve a transaction.
Blockchain / Solidity
owners = ['Alice', 'Bob', 'Carol'] requiredSignatures = 2
This wallet needs both owners to approve before sending money.
Blockchain / Solidity
owners = ['Dave', 'Eve'] requiredSignatures = 2
Sample Program
This program creates a multi-signature wallet with three owners. It submits a transaction, then owners confirm it. The transaction only executes after enough owners approve.
Blockchain / Solidity
class MultiSigWallet: def __init__(self, owners, required_signatures): self.owners = owners self.required_signatures = required_signatures self.transactions = {} self.confirmations = {} self.tx_count = 0 def submit_transaction(self, tx): tx_id = self.tx_count self.transactions[tx_id] = tx self.confirmations[tx_id] = set() self.tx_count += 1 print(f"Transaction {tx_id} submitted: {tx}") return tx_id def confirm_transaction(self, tx_id, owner): if owner not in self.owners: print(f"{owner} is not an owner.") return if tx_id not in self.transactions: print(f"Transaction {tx_id} does not exist.") return self.confirmations[tx_id].add(owner) print(f"{owner} confirmed transaction {tx_id}.") def execute_transaction(self, tx_id): if tx_id not in self.transactions: print(f"Transaction {tx_id} does not exist.") return if len(self.confirmations[tx_id]) >= self.required_signatures: print(f"Transaction {tx_id} executed: {self.transactions[tx_id]}") del self.transactions[tx_id] del self.confirmations[tx_id] else: print(f"Transaction {tx_id} needs more confirmations.") # Example usage owners = ['Alice', 'Bob', 'Carol'] wallet = MultiSigWallet(owners, 2) tx_id = wallet.submit_transaction('Send 10 coins to Dave') wallet.confirm_transaction(tx_id, 'Alice') wallet.execute_transaction(tx_id) # Not enough confirmations wallet.confirm_transaction(tx_id, 'Bob') wallet.execute_transaction(tx_id) # Now it executes
OutputSuccess
Important Notes
Multi-signature wallets increase security by requiring multiple approvals.
Each owner has a unique key to sign transactions.
Without enough confirmations, transactions cannot be executed.
Summary
Multi-signature wallets need several people to approve transactions.
This protects funds from being spent by one person alone.
They are useful for groups or companies managing shared money.