Skip to main content

Multisig Contract

4-of-7 threshold multisig for governance execution.

Storage

owners: StoredAddressArray        // List of 7 owners
isOwner: AddressMemoryMap // Quick lookup
threshold: StoredU256 // Required confirmations (4)
txCount: StoredU256 // Nonce for tx IDs

// Per transaction
txTarget: Map<u256, Address>
txSelector: Map<u256, u32>
txData: Map<u256, u256>
txConfirmCount: Map<u256, u256>
txExecuted: Map<u256, bool>

Transaction Flow

1. Propose

function propose(target, selector, data): u256 {
require(isOwner[sender]);

const txId = txCount++;
txTarget[txId] = target;
txSelector[txId] = selector;
txData[txId] = data;
txConfirmCount[txId] = 1; // Proposer auto-confirms

return txId;
}

2. Confirm

function confirm(txId): void {
require(isOwner[sender]);
require(!confirmations[txId][sender]);

confirmations[txId][sender] = true;
txConfirmCount[txId]++;
}

3. Execute

function execute(txId): void {
require(txConfirmCount[txId] >= threshold);
require(!txExecuted[txId]);

txExecuted[txId] = true;
Blockchain.call(txTarget[txId], encodeCall(txSelector[txId], txData[txId]));
}

Owner Management

// Add owner (requires 4-of-7)
function addOwner(owner): void {
onlySelf();
owners.push(owner);
isOwner[owner] = true;
}

// Remove owner (requires 4-of-7)
function removeOwner(owner): void {
onlySelf();
require(owners.length > threshold);
owners.remove(owner);
isOwner[owner] = false;
}

// Change threshold (requires 4-of-7)
function changeThreshold(newThreshold): void {
onlySelf();
require(newThreshold <= owners.length);
threshold = newThreshold;
}

View Functions

  • getOwners() - List of current owners
  • getTransaction(txId) - Transaction details
  • isConfirmed(txId, owner) - Check confirmation status