MultiSigWallet
Traditional N-of-M multi-signature wallet for entity control
Simple threshold signatures without roles or complex approval logic
State Variables
entityWallet
address public entityWallet;
owners
address[] public owners;
required
uint256 public required;
isOwner
mapping(address => bool) public isOwner;
transactions
Transaction[] public transactions;
Functions
onlyOwner
modifier onlyOwner();
txExists
modifier txExists(uint256 _txIndex);
notExecuted
modifier notExecuted(uint256 _txIndex);
notConfirmed
modifier notConfirmed(uint256 _txIndex);
constructor
constructor(address _entityWallet, address[] memory _owners, uint256 _required);
submitTransaction
Submit a transaction for multi-sig approval
function submitTransaction(address _target, uint256 _value, bytes memory _data)
public
onlyOwner
returns (uint256 txIndex);
Parameters
_target
address
Address to call
_value
uint256
Amount of ETH to send
_data
bytes
Transaction data
Returns
txIndex
uint256
Index of the submitted transaction
confirmTransaction
Confirm a pending transaction
function confirmTransaction(uint256 _txIndex) public onlyOwner txExists(_txIndex) notConfirmed(_txIndex);
Parameters
_txIndex
uint256
Index of transaction to confirm
revokeConfirmation
Revoke confirmation for a transaction
function revokeConfirmation(uint256 _txIndex) public onlyOwner txExists(_txIndex) notExecuted(_txIndex);
Parameters
_txIndex
uint256
Index of transaction
executeTransaction
Execute a confirmed transaction
function executeTransaction(uint256 _txIndex) public onlyOwner txExists(_txIndex) notExecuted(_txIndex);
Parameters
_txIndex
uint256
Index of transaction to execute
addOwner
Add a new owner (requires multi-sig approval)
function addOwner(address owner) public onlyOwner;
Parameters
owner
address
Address of new owner
removeOwner
Remove an owner (requires multi-sig approval)
function removeOwner(address owner) public onlyOwner;
Parameters
owner
address
Address to remove
changeRequirement
Change the number of required confirmations
function changeRequirement(uint256 _required) public onlyOwner;
Parameters
_required
uint256
New required confirmation count
_addOwner
function _addOwner(address owner) external;
_removeOwner
function _removeOwner(address owner) external;
_changeRequirement
function _changeRequirement(uint256 _required) external;
getOwners
Get list of owners
function getOwners() public view returns (address[] memory);
Returns
<none>
address[]
Array of owner addresses
getTransactionCount
Get transaction count
function getTransactionCount() public view returns (uint256);
Returns
<none>
uint256
Number of transactions
getTransaction
Get transaction details
function getTransaction(uint256 _txIndex)
public
view
returns (address target, uint256 value, bytes memory data, bool executed, uint256 confirmationCount);
Parameters
_txIndex
uint256
Transaction index
Returns
target
address
Target address
value
uint256
Transaction value
data
bytes
Transaction data
executed
bool
Whether executed
confirmationCount
uint256
Number of confirmations
isConfirmed
Check if transaction is confirmed by owner
function isConfirmed(uint256 _txIndex, address _owner) public view returns (bool);
Parameters
_txIndex
uint256
Transaction index
_owner
address
Owner address
Returns
<none>
bool
Whether transaction is confirmed by owner
getPendingTransactions
Get pending transactions (not yet executed)
function getPendingTransactions() public view returns (uint256[] memory indexes);
Returns
indexes
uint256[]
Array of pending transaction indexes
canExecute
Check if transaction has enough confirmations to execute
function canExecute(uint256 _txIndex) public view returns (bool);
Parameters
_txIndex
uint256
Transaction index
Returns
<none>
bool
Whether transaction can be executed
Events
Deposit
event Deposit(address indexed sender, uint256 amount, uint256 balance);
SubmitTransaction
event SubmitTransaction(
address indexed owner, uint256 indexed txIndex, address indexed target, uint256 value, bytes data
);
ConfirmTransaction
event ConfirmTransaction(address indexed owner, uint256 indexed txIndex);
RevokeConfirmation
event RevokeConfirmation(address indexed owner, uint256 indexed txIndex);
ExecuteTransaction
event ExecuteTransaction(address indexed owner, uint256 indexed txIndex);
OwnerAdded
event OwnerAdded(address indexed owner);
OwnerRemoved
event OwnerRemoved(address indexed owner);
RequirementChanged
event RequirementChanged(uint256 required);
Structs
Transaction
struct Transaction {
address target;
uint256 value;
bytes data;
bool executed;
uint256 confirmationCount;
mapping(address => bool) confirmations;
}
Last updated
Was this helpful?