Implements secure admin key rotation functionality for DAO multisig management. This feature provides a two-step process (propose → accept) to prevent accidental lockout while maintaining full audit trails and backward compatibility.
- ✅ transfer_ownership(new_admin) - Immediate transfer for backward compatibility
- ✅ Two-step process: propose_new_admin → accept_ownership to prevent accidental lockout
- ✅ 24-hour expiration on pending proposals
- ✅ Full audit logging for all admin actions
- ✅ Contract-specific and global admin management
- Two-Step Process:
propose_new_admin→accept_ownershipprevents lockout - Time-Limited Proposals: 24-hour expiration on pending transfers
- Address Validation: Comprehensive Ethereum address validation
- Audit Trail: Complete logging of all admin actions
proposeNewAdmin(currentAdmin, newAdmin, contract?): Create pending transfer proposalacceptOwnership(newAdmin, transferId): Complete the transfer processtransferOwnership(currentAdmin, newAdmin, contract?): Immediate transfer (backward compatibility)getPendingTransfers(contract?): View pending admin transfers
| Endpoint | Method | Description |
|---|---|---|
/api/admin/propose-new-admin |
POST | Propose new admin (creates pending transfer) |
/api/admin/accept-ownership |
POST | Accept ownership and complete transfer |
/api/admin/transfer-ownership |
POST | Immediate transfer (backward compatibility) |
/api/admin/pending-transfers |
GET | View pending admin transfers |
// Step 1: Current admin proposes new admin
const proposal = await adminService.proposeNewAdmin(
'0x1234...', // current admin
'0x5678...', // proposed admin
'0xabcd...' // optional contract address
);
// Step 2: Proposed admin accepts ownership
const transfer = await adminService.acceptOwnership(
'0x5678...', // new admin (must match proposal)
proposal.transferId
);// Direct transfer for emergency situations
const transfer = await adminService.transferOwnership(
'0x1234...', // current admin
'0x5678...', // new admin
'0xabcd...' // optional contract address
);- ✅ Global Admin Transfers: Test system-wide admin changes
- ✅ Contract-Specific Transfers: Test per-contract admin management
- ✅ Two-Step Flow: Complete proposal → acceptance workflow
- ✅ Error Handling: Invalid addresses, expired proposals, wrong transfer IDs
- ✅ Backward Compatibility: Immediate transfer functionality
- ✅ Audit Verification: Confirm all actions are logged
# Run admin key management tests
node test/adminKeyManagement.test.jscurl -X POST http://localhost:3000/api/admin/propose-new-admin \
-H "Content-Type: application/json" \
-d '{
"currentAdminAddress": "0x1234567890123456789012345678901234567890",
"newAdminAddress": "0x9876543210987654321098765432109876543210",
"contractAddress": "0xabcdef1234567890abcdef1234567890abcdef1234"
}'curl -X POST http://localhost:3000/api/admin/accept-ownership \
-H "Content-Type: application/json" \
-d '{
"newAdminAddress": "0x9876543210987654321098765432109876543210",
"transferId": "global_1642694400000"
}'curl -X POST http://localhost:3000/api/admin/transfer-ownership \
-H "Content-Type: application/json" \
-d '{
"currentAdminAddress": "0x1234567890123456789012345678901234567890",
"newAdminAddress": "0x9876543210987654321098765432109876543210"
}'- Two-Step Verification: Prevents accidental admin lockout
- Time-Bound Proposals: 24-hour expiration prevents stale transfers
- Address Validation: Comprehensive input validation
- Audit Logging: Complete traceability of all admin actions
- Invalid Addresses: Rejects malformed Ethereum addresses
- Duplicate Admins: Prevents proposing same admin as current
- Expired Proposals: Automatically cleans up expired transfers
- Transfer ID Validation: Ensures only valid transfers can be accepted
None. This is a purely additive feature that maintains full backward compatibility.
No new dependencies required. Uses existing Express.js framework and audit logging system.
This implementation directly addresses Issue 16: [Admin] Update Admin Key and provides:
- ✅ Security: Two-step process prevents accidental lockout
- ✅ Flexibility: Supports both global and contract-specific admin management
- ✅ Auditability: Complete audit trail for compliance
- ✅ Backward Compatibility: Immediate transfer option available
- ✅ Reliability: Comprehensive error handling and validation
For questions or issues:
- Review the test suite for usage examples
- Check audit logs via
/api/admin/audit-logsendpoint - Monitor pending transfers via
/api/admin/pending-transfersendpoint - Verify all admin addresses are valid Ethereum addresses
Resolves: #16 - [Admin] Update Admin Key Priority: High Labels: governance, security, enhancement